001 - MODULE VGACORE 002 - TITLE 'VGA signal generator core' 003 - 004 - DECLARATIONS 005 - " ------ external signals ------- 006 - reset PIN; "reset 007 - clock PIN; "VGA dot clock 008 - hsyncb PIN ISTYPE 'REG'; "horizontal sync 009 - vsyncb PIN ISTYPE 'REG'; "vertical (frame) sync 010 - red1 .. red0 PIN ISTYPE 'REG'; "red component 011 - green1 .. green0 PIN ISTYPE 'REG'; "green component 012 - blue1 .. blue0 PIN ISTYPE 'REG'; "blue component 013 - addr14 .. addr0 PIN; "address into video RAM 014 - data7 .. data0 PIN; "data from video RAM 015 - csb PIN; "video RAM chip select 016 - oeb PIN; "video RAM output enable 017 - web PIN; "video RAM write enable 018 - " ------ internal storage and signals ------- 019 - hcnt8 .. hcnt0 NODE ISTYPE 'REG'; "horizontal pixel counter 020 - vcnt9 .. vcnt0 NODE ISTYPE 'REG'; "vertical line counter 021 - pixrg7 .. pixrg0 NODE ISTYPE 'REG'; "byte - wide register for 4 pixels 022 - blank NODE ISTYPE 'COM'; "video blanking signal 023 - pblank NODE ISTYPE 'REG'; "pipelined blanking signal 024 - " ------ synonyms for various items ------- 025 - hcnt = [hcnt8 .. hcnt0]; 026 - vcnt = [vcnt9 .. vcnt0]; 027 - vram _ addr = [addr14 .. addr0]; 028 - vram _ data = [data7 .. data0]; 029 - pixrg = [pixrg7 .. pixrg0]; 030 - pixel = [pixrg1 .. pixrg0]; " current active 2 - bit pixel 031 - rgb = [red1 .. red0,green1 .. green0,blue1 .. blue0]; 032 - 033 - EQUATIONS 034 - 035 - @CARRY 1; " ripple - carry addition is fast enough 036 - 037 - hcnt . ACLR = reset; "clear counter on active - high reset 038 - vcnt . ACLR = reset; "clear counter on active - high reset 039 - hcnt . CLK = clock; "horz . pixel counter increments on each dot clock 040 - vcnt . CLK = hsyncb; "line counter increments after every horiz . line 041 - 042 - hsyncb . ASET = reset; 043 - vsyncb . ASET = reset; 044 - hsyncb . CLK = clock; 045 - vsyncb . CLK = hsyncb; 046 - 047 - "horiz . pixel counter rolls - over after 381 pixels 048 - WHEN (hcnt<380) THEN hcnt:=hcnt+1 ELSE hcnt:=0; 049 - "horiz . sync is low during this interval to signal start of a new line 050 - WHEN ((hcnt>=291)&(hcnt<337)) THEN hsyncb:=0 ELSE hsyncb:=1; 051 - "vertical line counter rolls - over after 528 lines 052 - WHEN (vcnt<527) THEN vcnt:=vcnt+1 ELSE vcnt:=0; 053 - "vert sync is low during this interval to signal the start of a frame 054 - WHEN ((vcnt>=490)&(vcnt<492)) THEN vsyncb:=0 ELSE vsyncb:=1; 055 - "blank video outside of visible region: (0,0) - >(255,479) 056 - WHEN ((hcnt>=256)#(vcnt>=480)) THEN blank=1 ELSE blank=0; 057 - "store the blanking signal for use in the next pipeline stage