]> Joshua Wise's Git repositories - fpgaboy.git/commitdiff
Yaaay, everything is posedge now
authorJoshua Wise <joshua@rebirth.joshuawise.com>
Sun, 4 May 2008 09:48:13 +0000 (05:48 -0400)
committerJoshua Wise <joshua@rebirth.joshuawise.com>
Sun, 4 May 2008 09:48:13 +0000 (05:48 -0400)
GBZ80Core.v
LCDC.v
System.v
bootrom.asm
sim.cmd

index b06910a6c3052f3c8648424e6926aac0a8953ce5..9db958fa85dc93189a0251b91d1b8cb5c600ff97 100644 (file)
@@ -314,8 +314,8 @@ module GBZ80Core(
                                        opcode <= `INSN_VOP_INTR;
                                else
                                        opcode <= {1'b0,busdata};
-                               rdata <= busdata;
                                newcycle <= 0;
+                               rdata <= busdata;
                                cycle <= 0;
                        end else begin
                                if (rd) rdata <= busdata;
diff --git a/LCDC.v b/LCDC.v
index f951d3a15ba7ea5af16709d6d7dd8b3446397009..a198c45d03ad806e4987cf3c3b7455ee9e704745 100644 (file)
--- a/LCDC.v
+++ b/LCDC.v
@@ -27,7 +27,7 @@ module LCDC(
        /***** Internal clock that is stable and does not depend on CPU in single/double clock mode *****/
        reg clk4 = 0;
        always @(posedge clk)
-               clk4 = ~clk4;
+               clk4 <= ~clk4;
        
        /***** LCD control registers *****/
        reg [7:0] rLCDC = 8'h00;
@@ -88,7 +88,7 @@ module LCDC(
        assign lcdcirq = (rSTAT[3] & mode00irq) | (rSTAT[4] & mode01irq) | (rSTAT[5] & mode10irq) | (rSTAT[6] & lycirq);
        assign vblankirq = (posx == 0 && posy == 153);
        
-       always @(negedge clk4)
+       always @(posedge clk4)
        begin
                if (posx == 455) begin
                        posx <= 0;
@@ -155,13 +155,12 @@ module LCDC(
        wire [11:0] tileaddr_in = vraminuse ? tileaddr : addr[12:1];
        
        always @(posedge clk)
+       begin
                if ((vraminuse && ((posx == 2) || (vxpos[2:0] == 3'b111))) || decode_bgmap1) begin
                        tileno <= bgmap1[bgmapaddr_in];
                        if (wr && decode_bgmap1 && ~vraminuse)
                                bgmap1[bgmapaddr_in] <= data;
                end
-       
-       always @(posedge clk)
                if ((vraminuse && ((posx == 3) || (vxpos[2:0] == 3'b000))) || decode_tiledata) begin
                        tilehigh <= tiledatahigh[tileaddr_in];
                        tilelow <= tiledatalow[tileaddr_in];
@@ -170,6 +169,7 @@ module LCDC(
                        if (wr && ~addr[0] && decode_tiledata && ~vraminuse)
                                tiledatalow[tileaddr_in] <= data;
                end
+       end
   
        /***** Bus interface *****/
        assign data = rd ?
index 8f54685cfd33045ea6ad52b80f155b379a17099e..1872e5125c6324c39a364ce1db44b095393136dc 100644 (file)
--- a/System.v
+++ b/System.v
@@ -6,12 +6,15 @@ module ROM(
        input clk,
        input wr, rd);
 
+       reg [7:0] odata;
+
        // synthesis attribute ram_style of rom is block
        reg [7:0] rom [1023:0];
        initial $readmemh("rom.hex", rom);
 
        wire decode = address[15:13] == 0;
-       wire [7:0] odata = rom[address[10:0]];
+       always @(posedge clk)
+               odata <= rom[address[10:0]];
        assign data = (rd && decode) ? odata : 8'bzzzzzzzz;
 endmodule
 
@@ -21,11 +24,11 @@ module BootstrapROM(
        input clk,
        input wr, rd);
 
-       reg [7:0] rom [255:0];
-       initial $readmemh("bootstrap.hex", rom);
+       reg [7:0] brom [255:0];
+       initial $readmemh("bootstrap.hex", brom);
 
        wire decode = address[15:8] == 0;
-       wire [7:0] odata = rom[address[7:0]];
+       wire [7:0] odata = brom[address[7:0]];
        assign data = (rd && decode) ? odata : 8'bzzzzzzzz;
 endmodule
 
index 4e780bf2918e045112731d9484c9c8afe172b3a7..26ba6e4ed0c6862e89d6ffc3726a681f09225b06 100644 (file)
@@ -1,175 +1,3 @@
-       SECTION "a",HOME[$00]
-
-       LD SP,$fffe             ; $0000  Setup Stack
-
-       XOR A                   ; $0003  Zero the memory from $8000-$9FFF (VRAM)
-       LD HL,$9fff             ; $0004
-Addr_0007:
-       LD [HLD],A              ; $0007
-       BIT 7,H         ; $0008
-       JR NZ, Addr_0007        ; $000a
-
-       LD HL,$ff26             ; $000c  Setup Audio
-       LD C,$11                ; $000f
-       LD A,$80                ; $0011 
-       LD [HLD],A              ; $0013
-       LD [C],A        ; $0014
-       INC C                   ; $0015
-       LD A,$f3                ; $0016
-       LD [C],A        ; $0018
-       LD [HLD],A              ; $0019
-       LD A,$77                ; $001a
-       LD [HLD],A              ; $001c
-
-       LD A,$fc                ; $001d  Setup BG palette
-       LD [$FF47],A    ; $001f
-
-       LD DE,$0104             ; $0021  Convert and load logo data from cart into Video RAM
-       LD HL,$8010             ; $0024
-Addr_0027:
-       LD A,[DE]               ; $0027
-       CALL a95                ; $0028
-       CALL a96                ; $002b
-       INC DE          ; $002e
-       LD A,E          ; $002f
-       CP $34          ; $0030
-       JR NZ, Addr_0027        ; $0032
-
-       LD DE,Addr_00D8         ; $0034  Load 8 additional bytes into Video RAM
-       LD B,$08                ; $0037
-Addr_0039:
-       LD A,[DE]               ; $0039
-       INC DE          ; $003a
-       LD [HLI],A              ; $003b
-       INC HL          ; $003c
-       DEC B                   ; $003d
-       JR NZ, Addr_0039        ; $003e
-
-       LD A,$19                ; $0040  Setup background tilemap
-       LD [$9910],A    ; $0042
-       LD HL,$992f             ; $0045
-Addr_0048:
-       LD C,$0c                ; $0048
-Addr_004A:
-       DEC A                   ; $004a
-       JR Z, Addr_0055 ; $004b
-       LD [HLD],A              ; $004d
-       DEC C                   ; $004e
-       JR NZ, Addr_004A        ; $004f
-       LD L,$0f                ; $0051
-       JR Addr_0048    ; $0053
-
-       ; === Scroll logo on screen, and play logo sound===
-
-Addr_0055:
-       LD H,A          ; $0055  Initialize scroll count, H=0
-       LD A,$64                ; $0056
-       LD D,A          ; $0058  set loop count, D=$64
-       LD [$FF42],A    ; $0059  Set vertical scroll register
-       LD A,$91                ; $005b
-       LD [$FF40],A    ; $005d  Turn on LCD, showing Background
-       INC B                   ; $005f  Set B=1
-Addr_0060:
-       LD E,$02                ; $0060
-Addr_0062:
-       LD C,$0c                ; $0062
-Addr_0064:
-       LD A,[$FF44]    ; $0064  wait for screen frame
-       CP $90          ; $0066
-       JR NZ, Addr_0064        ; $0068
-       DEC C                   ; $006a
-       JR NZ, Addr_0064        ; $006b
-       DEC E                   ; $006d
-       JR NZ, Addr_0062        ; $006e
-
-       LD C,$13                ; $0070
-       INC H                   ; $0072  increment scroll count
-       LD A,H          ; $0073
-       LD E,$83                ; $0074
-       CP $62          ; $0076  $62 counts in, play sound #1
-       JR Z, Addr_0080 ; $0078
-       LD E,$c1                ; $007a
-       CP $64          ; $007c
-       JR NZ, Addr_0086        ; $007e  $64 counts in, play sound #2
-Addr_0080:
-       LD A,E          ; $0080  play sound
-       LD [C],A        ; $0081
-       INC C                   ; $0082
-       LD A,$87                ; $0083
-       LD [C],A        ; $0085
-Addr_0086:
-       LD A,[$FF42]    ; $0086
-       SUB B                   ; $0088
-       LD [$FF42],A    ; $0089  scroll logo up if B=1
-       DEC D                   ; $008b  
-       JR NZ, Addr_0060        ; $008c
-
-       DEC B                   ; $008e  set B=0 first time
-       JR NZ, Addr_00E0        ; $008f    ... next time, cause jump to "Nintendo Logo check"
-
-       LD D,$20                ; $0091  use scrolling loop to pause
-       JR Addr_0060    ; $0093
-
-       ; ==== Graphic routine ====
-
-a95:   LD C,A          ; $0095  "Double up" all the bits of the graphics data
-a96:   LD B,$04                ; $0096     and store in Video RAM
-Addr_0098:
-       PUSH BC         ; $0098
-       RL C                    ; $0099
-       RLA                     ; $009b
-       POP BC          ; $009c
-       RL C                    ; $009d
-       RLA                     ; $009f
-       DEC B                   ; $00a0
-       JR NZ, Addr_0098        ; $00a1
-       LD [HLI],A              ; $00a3
-       INC HL          ; $00a4
-       LD [HLI],A              ; $00a5
-       INC HL          ; $00a6
-       RET                     ; $00a7
-
-NintendoLogo:
-       ;Nintendo Logo
-       DB $CE,$ED,$66,$66,$CC,$0D,$00,$0B,$03,$73,$00,$83,$00,$0C,$00,$0D 
-       DB $00,$08,$11,$1F,$88,$89,$00,$0E,$DC,$CC,$6E,$E6,$DD,$DD,$D9,$99 
-       DB $BB,$BB,$67,$63,$6E,$0E,$EC,$CC,$DD,$DC,$99,$9F,$BB,$B9,$33,$3E 
-
-Addr_00D8:
-       ;More video data
-       DB $3C,$42,$B9,$A5,$B9,$A5,$42,$3C
-
-       ; ===== Nintendo logo comparison routine =====
-
-Addr_00E0:     
-       LD HL,$0104             ; $00e0 ; point HL to Nintendo logo in cart
-       LD DE,NintendoLogo      ; $00e3 ; point DE to Nintendo logo in DMG rom
-
-Addr_00E6:
-       LD A,[DE]               ; $00e6
-       INC DE          ; $00e7
-       CP [HL]         ; $00e8 ;compare logo data in cart to DMG rom
-.fuq   JR NZ,.fuq              ; $00e9 ;if not a match, lock up here
-       INC HL          ; $00eb
-       LD A,L          ; $00ec
-       CP $34          ; $00ed ;do this for $30 bytes
-       JR NZ, Addr_00E6        ; $00ef
-
-       LD B,$19                ; $00f1
-       LD A,B          ; $00f3
-Addr_00F4:
-       ADD [HL]                ; $00f4
-       INC HL          ; $00f5
-       DEC B                   ; $00f6
-       JR NZ, Addr_00F4        ; $00f7
-       ADD [HL]                ; $00f9
-.fuq:  JR NZ,.fuq              ; $00fa ; if $19 + bytes from $0134-$014D  don't add to $00
-                                               ;  ... lock up
-
-       LD A,$01                ; $00fc
-       LD [$FF50],A    ; $00fe ;turn off DMG rom
-
-
        SECTION "b",HOME[$100]
 boot:  jr .running     ; $0100
        nop             ; $0102
diff --git a/sim.cmd b/sim.cmd
index abd34aec88f5ee28e944514ee8c366ff55685d85..154489f79c97a17e8c82c8c23e4cd0d8c5cd2c28 100644 (file)
--- a/sim.cmd
+++ b/sim.cmd
@@ -1,3 +1,3 @@
 vcd dumpfile /proc/self/fd/[string range [open |./readout "w"] 4 1000]
 vcd dumpvars -m Dumpable
-run 1000ms
+run all
This page took 0.040751 seconds and 4 git commands to generate.