-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
187 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
inst_table = { | ||
"LDV" : "0000", | ||
"STVI" : "0001", | ||
"ADD" : "0101", | ||
"SUB" : "0110", | ||
"LOAD" : "0100", | ||
"STORE" : "0011", | ||
"JUMP" : "1" | ||
"JNZ" : "1" | ||
} | ||
|
||
space_table = { | ||
"code" : 128, | ||
"unused" : 112, | ||
"video" : 80, | ||
"unused" : 32, | ||
"data" : 16 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
loop: | ||
LDV | ||
SUB a | ||
STVI | ||
delay: | ||
SUB a | ||
JNZ delay | ||
LOAD a | ||
JNZ loop | ||
|
||
.video 0x00,0x00,0x01,0x02,0x03,0x03,0x04,0x05,0x06,0x07,0x07,0x08,0x09,0x0A,0x0B,0x0B,0x0C,0x0D,0x0E,0x0F,0x0F,0x10,0x11,0x12,0x13,0x13,0x14,0x15,0x16,0x17,0x17,0x18,0x19,0x1A,0x1B,0x1B,0x1C,0x1D,0x1E,0x1F,0x1F,0x20,0x21,0x22,0x23,0x23,0x24,0x25,0x26,0x27,0x27,0x28,0x29,0x2A,0x2B,0x2B,0x2C,0x2D,0x2E,0x2F,0x2F,0x30,0x31,0x32,0x33,0x33,0x34,0x35,0x36,0x37,0x37,0x38,0x39,0x3A,0x3B,0x3B,0x3C,0x3D,0x3E,0x3F | ||
.a 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Substitutes Xilinx IP core for simulation purposes | ||
module clk_wiz_1(output clk_out, input clk_in); | ||
assign clk_out = clk_in; | ||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module power_on_reset( | ||
input clk, | ||
output reset); | ||
|
||
reg q0 = 1'b0; | ||
reg q1 = 1'b0; | ||
reg q2 = 1'b0; | ||
|
||
always@(posedge clk) | ||
begin | ||
q0 <= 1'b1; | ||
q1 <= q0; | ||
q2 <= q1; | ||
end | ||
|
||
assign reset = !(q0 & q1 & q2); | ||
endmodule | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module tb; | ||
reg clock; | ||
|
||
top dut(clock); | ||
|
||
initial | ||
begin | ||
$dumpfile("dump.vcd"); $dumpvars(0); | ||
#50000; $stop; | ||
end | ||
|
||
always | ||
begin | ||
clock <= 1; #5; clock <= 0; #5; | ||
end | ||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,17 @@ | ||
module up_tb; | ||
logic clock, reset, we; | ||
logic [7:0] address, ir, pc; | ||
wire [7:0] data; | ||
|
||
uP proc(clock, reset, data, we, address, pc, ir); | ||
// mem #("fibo.hex") ram(clock, we, address, data); | ||
mem #("fibo.bin") ram(clock, we, address, data); | ||
|
||
initial | ||
begin | ||
$dumpfile("dump.vcd"); $dumpvars(0); | ||
reset <= 1; #22; reset <= 0; | ||
#5000; $stop; | ||
end | ||
module top( | ||
input sysclk, // 125MHz | ||
output [3:0] led, | ||
output led5_r, led5_g, led5_b, led6_r, led6_g, led6_b, | ||
output [3:0] VGA_R, VGA_G, VGA_B, | ||
output VGA_HS_O, VGA_VS_O); | ||
|
||
always | ||
begin | ||
clock <= 1; #5; clock <= 0; #5; | ||
end | ||
wire pixel_clk, reset, we; | ||
wire [7:0] address, data, vaddr, vdata; | ||
|
||
power_on_reset por(sysclk, reset); | ||
clk_wiz_1 clockdiv(pixel_clk, sysclk); // 25MHz | ||
cpu proc(sysclk, reset, data, we, address); | ||
mem #("vga.bin") ram(sysclk, we, address, data, vaddr, vdata); | ||
vga video(pixel_clk, reset, vdata, vaddr, VGA_R, VGA_G, VGA_B, VGA_HS_O, VGA_VS_O); | ||
endmodule | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
module vga( | ||
input clk, reset, | ||
input [7:0] vdata, | ||
output [7:0] vaddr, | ||
output [3:0] VGA_R, VGA_G, VGA_B, | ||
output VGA_HS_O, VGA_VS_O); | ||
|
||
reg [9:0] CounterX, CounterY; | ||
reg inDisplayArea; | ||
reg vga_HS, vga_VS; | ||
|
||
wire CounterXmaxed = (CounterX == 800); // 16 + 48 + 96 + 640 | ||
wire CounterYmaxed = (CounterY == 525); // 10 + 2 + 33 + 480 | ||
wire [3:0] row, col; | ||
|
||
always @(posedge clk or posedge reset) | ||
if (reset) | ||
CounterX <= 0; | ||
else | ||
if (CounterXmaxed) | ||
CounterX <= 0; | ||
else | ||
CounterX <= CounterX + 1; | ||
|
||
always @(posedge clk or posedge reset) | ||
if (reset) | ||
CounterY <= 0; | ||
else | ||
if (CounterXmaxed) | ||
if(CounterYmaxed) | ||
CounterY <= 0; | ||
else | ||
CounterY <= CounterY + 1; | ||
|
||
assign row = (CounterY>>6); | ||
assign col = (CounterX>>6); | ||
assign vaddr = {1'b1,col[3:0],row[2:0]}; | ||
|
||
always @(posedge clk) | ||
begin | ||
vga_HS <= (CounterX > (640 + 16) && (CounterX < (640 + 16 + 96))); // active for 96 clocks | ||
vga_VS <= (CounterY > (480 + 10) && (CounterY < (480 + 10 + 2))); // active for 2 clocks | ||
inDisplayArea <= (CounterX < 640) && (CounterY < 480); | ||
end | ||
|
||
assign VGA_HS_O = ~vga_HS; | ||
assign VGA_VS_O = ~vga_VS; | ||
|
||
assign VGA_R = inDisplayArea ? {vdata[5:4], 2'b00} : 4'b0000; | ||
assign VGA_G = inDisplayArea ? {vdata[3:2], 2'b00} : 4'b0000; | ||
assign VGA_B = inDisplayArea ? {vdata[1:0], 2'b00} : 4'b0000; | ||
endmodule |