소스 코드 수정중인데 안나오네

vga640x480 vga(

CLOCK_50,

KEY[0],

LED,

GP0[6],

GP0[5],

{GP0[16],GP0[19],GP0[18],GP0[21]},

{GP0[12],GP0[15],GP0[14],GP0[17]},

{GP0[8],GP0[9],GP0[10],GP0[13]}

); 


module vga640x480(

input clk,

input rst,

output [7:0] LED,

output hsync,

output vsync,

output [3:0] r,

output [3:0] g,

output [3:0] b

);


parameter HSYNC = 189;

parameter HBP = (HSYNC + 95);

parameter HVID = (HBP + 1260);

parameter HFP = (HVID + 47);


parameter VSYNC = 3000;

parameter VBP = (VSYNC + 51000);

parameter VVID = (VBP + 762500);

parameter VFP = (VVID + 17500);


reg [19:0] cnt;


always @ (posedge clk or negedge rst)

begin

if (!rst)

begin

cnt <= 0;

end

else

begin

cnt <= cnt + 1;

if(cnt > 834000)

cnt <= 0;

end

end


assign hsync = ((cnt % 1590) < 189) ? 0 : 1;

assign vsync = (cnt < 3000) ? 0 : 1;

assign r = ((hsync & vsync) == 1 ? 4'b1111 : 4'b0000);

assign g = ((hsync & vsync) == 1 ? 4'b1111 : 4'b0000);

assign b = ((hsync & vsync) == 1 ? 4'b1111 : 4'b0000);

assign LED[0] = ~vsync;

assign LED[1] = ~hsync;


endmodule 


V sync는 59.95

H sync는 31.31kHz 이고


sync 길이도 파형도 맞는거 같은데..

Vsync 60us 근처

Hsync 4us 근처


왜 안될까...



+

module vga800x600x60(

input clk,

input rst,

output [7:0] LED,

output hsync,

output vsync,

output [3:0] r,

output [3:0] g,

output [3:0] b

);


parameter HSYNC = 160;

parameter HBP = (HSYNC + 95);

parameter HVID = (HBP + 1260);

parameter HFP = (HVID + 47);


parameter VSYNC = 5300;

parameter VBP = (VSYNC + 51000);

parameter VVID = (VBP + 762500);

parameter VFP = (VVID + 17500);


reg [19:0] cnt;


always @ (posedge clk or negedge rst)

begin

if (!rst)

begin

cnt <= 0;

end

else

begin

cnt <= cnt + 1;

if(cnt > 828950)

cnt <= 0;

end

end


assign hsync = ((cnt % 1320) < 160) ? 0 : 1;

assign vsync = (cnt < 5300) ? 0 : 1;

assign r = ((hsync & vsync) == 1 ? 4'b1111 : 4'b0000);

assign g = ((hsync & vsync) == 1 ? 4'b1111 : 4'b0000);

assign b = ((hsync & vsync) == 1 ? 4'b1111 : 4'b0000);

assign LED[0] = ~vsync;

assign LED[1] = ~hsync;


endmodule  



For VESA 800*600 @ 60Hz: 

Fh (kHz) :37.88 

A (us) :26.4 

B (us) :3.2 

C (us) :2.2 

D (us) :20.0 

E (us) :1.0 


Fv (Hz) :60.32 

O (ms) :16.579 

P (ms) :0.106 

Q (ms) :0.607 

R (ms) :15.84 

S (ms) :0.026 

[링크 : http://www.epanorama.net/documents/pc/vga_timing.html]


+

640x480x60 에 빨간화면 확인

vga640x480 vga(

CLOCK_50,

KEY[0],

LED,

GP0[6],

GP0[5],

{GP0[16],GP0[19],GP0[18],GP0[21]},

{GP0[12],GP0[15],GP0[14],GP0[17]},

{GP0[8],GP0[9],GP0[10],GP0[13]}

); 


모니터에 따라 인식이 느리거나 안되기도 하네..

848x640x60 으로 인식... 머야(요즘 24인치 FHD LCD 모니터)

module vga640x480(

input clk,

input rst,

output [7:0] LED,

output reg hsync,

output reg vsync,

output [3:0] r,

output [3:0] g,

output [3:0] b

);


reg clk25;

reg [9:0] horizontal_counter;

reg [9:0] vertical_counter;


reg [9:0] X;

reg [9:0] Y;


wire [7:0] red;

wire [7:0] green;

wire [7:0] blue;


assign r[3:0] = ((horizontal_counter >= 144) 

&& (horizontal_counter < 784) 

&& (vertical_counter >=39)

&& (vertical_counter < 519)) ? 4'b1111 : 4'b000; 

assign g[1:0] = ((horizontal_counter >= 144) 

&& (horizontal_counter < 784) 

&& (vertical_counter >=39)

&& (vertical_counter < 519)) ? 4'b1111 : 4'b000; 

assign b[2:0] = ((horizontal_counter >= 144) 

&& (horizontal_counter < 784) 

&& (vertical_counter >=39)

&& (vertical_counter < 519)) ? 4'b1111 : 4'b000; 

assign red =   ((horizontal_counter >= 144)&&(horizontal_counter < 344) ) ? 4'b1111 : 4'b0000;

assign green = ((horizontal_counter >= 344)&&(horizontal_counter < 544) ) ? 4'b1111 : 4'b0000;

assign blue =  ((horizontal_counter >= 544)&&(horizontal_counter < 784) ) ? 4'b1111 : 4'b0000;


always @(posedge clk)

begin


if (clk25 == 0)

begin

   clk25 <= 1;

end   

else

begin

clk25 <= 0;

   end

end



always @(posedge clk25)

begin

if ((horizontal_counter > 0) && (horizontal_counter < 97))// -- 96+1

begin

hsync <= 0;

end

else

begin

hsync <= 1;

end 

if ((vertical_counter > 0 ) && (vertical_counter < 3 )) //-- 2+1

begin

vsync <= 0;

end

else

begin

vsync <= 1;

end

horizontal_counter <= horizontal_counter+1;

    

if (horizontal_counter == 800) 

begin

vertical_counter <= vertical_counter+1;

horizontal_counter <= 0;

end

    

if (vertical_counter == 521)

begin

vertical_counter <= 0;

end

end

endmodule  


[링크 : https://github.com/pmezydlo/DE0-Nano-SOC-VGA/blob/master/vgaram.v]

Posted by 구차니
embeded/FPGA - ALTERA2018. 6. 5. 10:55
Posted by 구차니

reset키(key[0])를 누르고있는 동안에는 영상이 나온다.

단순하게 posedge를 negedge로 바꾸려고 하는데 에러나네.. ㅠㅠ


빨강이 옆에 번지는건 왜일까..


800x600 72Hz 라고 출력된다.



vga_demo vga(

CLOCK_50,

KEY[0],

GP0[16],

GP0[12],

GP0[8],

GP0[6],

GP0[5],

); 


/*

VGA Demo 800x600 at 72Hz

http://www-mtl.mit.edu/Courses/6.111/labkit/vga.shtml

800x600, 72Hz 50.000 800 56 120 64 600 37 6 23

Pixel Clock (MHz): 50.000 

Horizontal (in Pixels)

    Active Video: 800 (16us)

    Front Porch:   56 (1.12us)

    Sync Pulse:   120 (2.4us)

    Back Porch:    64 (1.28us)

        Total pixel clock ticks: 1040 (20.8us)

Vertical (in Lines, so x20.8us)

    Active Video: 600 (12480us)

    Front Porch:   37 (769.6us)

    Sync Pulse:     6 (124.8us)

    Back Porch:    23 (478.4us)

        Total pixel clock ticks: 666 (13.32us)

Total pixel clock ticks: 692,640

50,000,000 / 692,640 = 72.187572188 = 72Hz

1 pixel clock = 1/50Mhz = 20ns = 0.02us

*/


module vga_demo

    (

        CLOCK_50,

        RESET,

        VGA_RED,

        VGA_GREEN,

        VGA_BLUE,

        VGA_HS,

        VGA_VS

    );

    input CLOCK_50;

    input RESET;

    output VGA_RED;

    output VGA_GREEN;

    output VGA_BLUE;

    output VGA_HS;

    output VGA_VS;


    /* Internal registers for horizontal signal timing */

    reg [10:0] hor_reg; // to count 1040 different values up to 1039

    reg hor_sync;

    wire hor_max = (hor_reg == 1039); // to tell when a line is full


    /* Internal registers for vertical signal timing */

    reg [9:0] ver_reg; // to count 666 different values up to 665

    reg ver_sync;

    reg red, green, blue;

    wire ver_max = (ver_reg == 665); // to tell when a line is full


    // Code


    

    /* Running through line */

    always @ (posedge CLOCK_50 or posedge RESET) begin


        if (RESET) begin 

            hor_reg <= 0;

            ver_reg <= 0;

        end

        else if (hor_max) begin

            hor_reg <= 0;


            /* Running through frame */

            if (ver_max)

                ver_reg <= 0;

            else

            ver_reg <= ver_reg + 1;


        end else

            hor_reg <= hor_reg + 1;


    end

    

    always @ (posedge CLOCK_50 or posedge RESET) begin

    

        if (RESET) begin 

            hor_sync <= 0;

            ver_sync <= 0;

        end

        else begin


            /* Generating the horizontal sync signal */

            if (hor_reg == 856)      // video (800) + front porch (56)

                hor_sync <= 1;       // turn on horizontal sync pulse

            else if (hor_reg == 976) // video (800) + front porch (56) + Sync Pulse (120)

                hor_sync <= 0;       // turn off horizontal sync pulse


            /* Generating the vertical sync signal */

            if (ver_reg == 637)      // LINES: video (600) +  front porch (37)

                ver_sync <= 1;       // turn on vertical sync pulse

            else if (ver_reg == 643) // LINES: video (600) + front porch (37) + Sync Pulse (6)

                ver_sync <= 0;       // turn off vertical sync pulse


                

            // Draw a single square.

            if (hor_reg >= 100 && hor_reg <= 200 && ver_reg >= 100 && ver_reg <= 200) begin

                red <= 1;

                green <= 0;

                blue <= 0;

            end 

            else begin

                red <= 1;

                green <= 1;

                blue <= 1;

            end

                

        end

    end


    // Send the sync signals to the output, inverted as the sync pulse is low.

    // Maybe wrong as this doc says pulse id positive http://tinyvga.com/vga-timing/800x600@72Hz

    assign VGA_HS = ~hor_sync;

    assign VGA_VS = ~ver_sync;

    

    // Send a pattern of colours (based on the registry bits) but do not output anything during the synchronization periods

    //assign VGA_RED = (!hor_reg[0] && !ver_reg[0] && ver_reg < 600 && hor_reg < 800);

    //assign VGA_GREEN = (!hor_reg[1] && !ver_reg[1] && ver_reg < 600 && hor_reg < 800);

    //assign VGA_BLUE = (!hor_reg[2] && !ver_reg[2] && ver_reg < 600 && hor_reg < 800);

    

    assign VGA_RED =  red && ver_reg < 600 && hor_reg < 800;

    assign VGA_GREEN = green && ver_reg < 600 && hor_reg < 800;

    assign VGA_BLUE = blue && ver_reg < 600 && hor_reg < 800;    

    

    // http://gerfficient.com/2013/02/11/fpga-to-vga-using-de0-nano/

    

endmodule 

[링크 : https://github.com/theapi/de0-nano/blob/master/vga/experiment/vga_demo.v]

Posted by 구차니
embeded/FPGA - ALTERA2018. 6. 4. 16:32

일단 하나 검색했으니 집에가서 따라해봐야지


RTL Level Simulation with ModelSim

- Synthesis 이후에 시뮬레이션 가능

Gate Level Simulation

- 전체 컴파일 이후에 시뮬레이션 가능

[링크 : http://idlelogiclabs.com/2011/12/04/using-modelsim-with-quartus-ii-and-the-de0-nano/]


게이트-레벨시뮬레이션은타이밍시뮬레이션에서 기능적결과의차이만을확인한다. 만약게이트-레벨시뮬레 이션은문제없고타이밍시뮬레이션이실패했다면, 넷리스트 가아닌타이밍으로발생된부분임을나타낸다. 백-어노테이트 타이밍 시뮬레이션은 타이밍 정보가 있는 게이트-레벨 시뮬레이션이다. 이를 위해 FPGA 벤더는 VITAL (VHDL Gate Level) 넷리스트 또는 Verilog 넷리스 트를 생성한다 

[링크 : http://www.itfind.or.kr/COMIN/file24639-FPGA%20디버깅%20방법.pdf]

Posted by 구차니
embeded/FPGA - ALTERA2018. 6. 3. 23:07

output 대신에

output reg를 쓰니 해결..

c언어 때 처럼 무슨 문제인지 감이 영안오네...


[링크 : https://electronics.stackexchange.com/...left-hand-side-of-assignment-must-have-a-variable-data-type]

Posted by 구차니

하다 보면 언젠간 언어도 익히고 작동도 하겠지머..

일단 sync만 인식을 하는지 절전모드였던 모니터가 살아나기는 하는데 해상도 정보까진 못 띄우네

DE0-nano에 시도중

vga640x480 vga(

CLOCK_50,

KEY[0],

LED,

GP0[6],

GP0[5],

{GP0[16],GP0[19],GP0[18],GP0[21]},

{GP0[12],GP0[15],GP0[14],GP0[17]},

{GP0[8],GP0[9],GP0[10],GP0[13]}

); 


module vga640x480(

input clk,

input rst,

output [7:0] LED,

output reg hsync,

output reg vsync,

output [3:0] r,

output [3:0] g,

output [3:0] b

);


parameter HSYNC = 189;

parameter HBP = (HSYNC + 95);

parameter HVID = (HBP + 1260);

parameter HFP = (HVID + 47);


parameter VSYNC = 3000;

parameter VBP = (VSYNC + 51000);

parameter VVID = (VBP + 762500);

parameter VFP = (VVID + 17500);


reg [19:0] cnt;


always @ (posedge clk or negedge rst)

begin

if (~rst)

cnt <= 0;

else

begin

if(cnt < 834000)

begin

cnt <= cnt + 1;

if((cnt % 1590) < HSYNC)

hsync <= 1;

else hsync <= 0;

if(cnt < VSYNC)

vsync <= 1;

else vsync <= 0;

end

else

cnt <= 0;

end

end


assign LED[0] = vsync;

assign LED[1] = hsync;


endmodule 


위의 수치는 아래의 계산에 의해서 나온 것 임.

vga_640x480.xlsx


+

parameter는 이전 값을 더해서 쓸수는 없는건가..

HFP를 이용해서 % 연산을 하면 정상적으로 작동하지 않는 것으로 보이네..



+

sync 구간에만 0이고 나머지는 1로 vsync/hsync 출력해야 하네?

[링크 : https://ws0.org/how-to-generate-a-vga-signal-with-a-fpga/]

[링크 : http://www.cs.ucr.edu/~jtarango/cs122a_lab4.html]

[링크 : https://www.nandland.com/goboard/vga-introduction-test-patterns.html]


+

단순하게 데이터만 출력한다고 나오는게 아닌가?

아무튼.. modelsim 쓰는법 배워서 출력 시그널 확인을 할 필요가 있을 듯...

module vga640x480(

input clk,

input rst,

output [7:0] LED,

output reg hsync,

output reg vsync,

output reg [3:0] r,

output reg [3:0] g,

output reg [3:0] b

);


parameter HSYNC = 189;

parameter HBP = (HSYNC + 95);

parameter HVID = (HBP + 1260);

parameter HFP = (HVID + 47);


parameter VSYNC = 3000;

parameter VBP = (VSYNC + 51000);

parameter VVID = (VBP + 762500);

parameter VFP = (VVID + 17500);


reg [19:0] cnt;


always @ (posedge clk or negedge rst)

begin

if (~rst)

begin

cnt <= 0;

hsync <= 1;

vsync <= 1;

end

else

begin

if(cnt < 834000)

begin

cnt <= cnt + 1;

if((cnt % 1590) < HSYNC)

hsync <= 0;

else hsync <= 1;

if(cnt < VSYNC)

vsync <= 0;

else vsync <= 1;

if(vsync & hsync)

begin

r <= 4'b1111;

g <= 4'b1111;

b <= 4'b1111;

end

else

begin

r <= 4'b0000;

g <= 4'b0000;

b <= 4'b0000;

end

end

else

cnt <= 0;

end

end


assign LED[0] = ~vsync;

assign LED[1] = ~hsync;


endmodule 


+

2018.06.04

하드웨어 구조는 모르겠지만 동일 셋트 예제 발견

[링크 : https://github.com/theapi/de0-nano/blob/master/vga/experiment/vga_demo.v]

Posted by 구차니

만사 귀찮네

접기에는 아깝고 

방문자 보고 시작한것도 아니긴 하지만

관리자 페이지에서 방문자 통계좀 없앴으면..


자꾸 너무 신경쓰이네..

Posted by 구차니
embeded/FPGA - ALTERA2018. 6. 2. 22:36

카운터 증가 하는데

클럭에 연계해서 작동시키는 부분에서

클럭 엣지 트리거 부분에 여러개 작성하니 에러 발생..


 always @ (posedge clk or negedge rst)

begin

if (~rst)

cnt <= 0;

else

begin

if(cnt < 834000)

cnt <= cnt + 1;

else

cnt <= 0;

end

if(cnt < HSYNC)

hsync <= 1;

else hsync <= 0;

if(cnt < VSYNC)

vsync <= 1;

else vsync <= 0;

end


아래는 해결 한 것

음.. 자세한 내용은 나중에 찾아봐야지.. 이해를 못하고 있음 ㅠㅠ

 always @ (posedge clk or negedge rst)

begin

if (~rst)

cnt <= 0;

else

begin

if(cnt < 834000)

begin

cnt <= cnt + 1;

if(cnt < HSYNC)

hsync <= 1;

else hsync <= 0;

if(cnt < VSYNC)

vsync <= 1;

else vsync <= 0;

end

else

cnt <= 0;

end

end


[링크 : https://www.edaboard.com/showthread.php?326768...-enclosing]

Posted by 구차니

피곤피곤..

'개소리 왈왈 > 육아관련 주저리' 카테고리의 다른 글

체력 방전  (0) 2018.06.09
체력 오링..  (0) 2018.06.06
월차, 아내님 병원 그리고 드론  (8) 2018.05.28
주말이 머했는데 끝나냐...  (0) 2018.05.27
대충대충 한쪽벽면 보온벽지 시공  (0) 2018.05.26
Posted by 구차니
개소리 왈왈/독서2018. 6. 1. 22:08

책 쓰고 싶어지는 책

그리고 블로그 접고 위키에 본격적으로 집필을 해서

완전히 다 쓰고 나서 출판사 접촉을 해봐야 하나 생각이 드네


그나저나 쓴다면 멀 주제로 써야 할까...


[링크 : http://www.kyobobook.co.kr/product/detailViewKor.laf?barcode=9788998294366]


+

처음 글을 쓰려는 사람에게 이런이런 과정이 있으니

이런식으로 따라오면 출판이 용이할 것이다. 라는 내용과

출판사 측의 의견들도 포함되서 책을 출판해보고 싶으나 해본적은 없는 사람에게 상당히 도움이 되는 책이다.

다만 책을 너무 쓰라고 종용(?) 하는 느낌이 조금 부담이 가고

뒤로 갈수록 책을 쓰는 이유가 현실적이긴 하지만 너무 금전적인 부분에 강조하는 게 거부감이 드는 정도?


나쁘게 말하자면 저자가 책에서도 말했듯

이런 정도 밖에 안되는 책도 출판되니 도전은 해보자!

내돈내고 하는것도 아니고 출판사가 위험을 짊어지고 하는거니 질러나 봐라 정도?


+

근데 동일 제목으로 다른 저자의 책이 또 있네?

Posted by 구차니