added v2.0
This commit is contained in:
34
03_Sequential_Logic/05_RAM3840/Include.v
Normal file
34
03_Sequential_Logic/05_RAM3840/Include.v
Normal file
@@ -0,0 +1,34 @@
|
||||
`include "../../01_Boolean_Logic/Nand.v"
|
||||
`include "../../01_Boolean_Logic/Not.v"
|
||||
`include "../../01_Boolean_Logic/Buffer.v"
|
||||
`include "../../01_Boolean_Logic/And.v"
|
||||
`include "../../01_Boolean_Logic/Or.v"
|
||||
`include "../../01_Boolean_Logic/Xor.v"
|
||||
`include "../../01_Boolean_Logic/Mux.v"
|
||||
`include "../../01_Boolean_Logic/DMux.v"
|
||||
`include "../../01_Boolean_Logic/Not16.v"
|
||||
`include "../../01_Boolean_Logic/Buffer16.v"
|
||||
`include "../../01_Boolean_Logic/And16.v"
|
||||
`include "../../01_Boolean_Logic/Or16.v"
|
||||
`include "../../01_Boolean_Logic/Mux16.v"
|
||||
`include "../../01_Boolean_Logic/Or8Way.v"
|
||||
`include "../../01_Boolean_Logic/Mux4Way16.v"
|
||||
`include "../../01_Boolean_Logic/Mux8Way16.v"
|
||||
`include "../../01_Boolean_Logic/DMux4Way.v"
|
||||
`include "../../01_Boolean_Logic/DMux8Way.v"
|
||||
|
||||
`include "../../02_Boolean_Arithmetic/HalfAdder.v"
|
||||
`include "../../02_Boolean_Arithmetic/FullAdder.v"
|
||||
`include "../../02_Boolean_Arithmetic/Add16.v"
|
||||
`include "../../02_Boolean_Arithmetic/Inc16.v"
|
||||
`include "../../02_Boolean_Arithmetic/ALU.v"
|
||||
|
||||
`include "../../03_Sequential_Logic/DFF.v"
|
||||
`include "../../03_Sequential_Logic/Bit.v"
|
||||
`include "../../03_Sequential_Logic/Register.v"
|
||||
`include "../../03_Sequential_Logic/PC.v"
|
||||
`include "../../03_Sequential_Logic/RAM256.v"
|
||||
`include "../../03_Sequential_Logic/RAM512.v"
|
||||
`include "../../03_Sequential_Logic/RAM3840.v"
|
||||
`include "../../03_Sequential_Logic/BitShift8L.v"
|
||||
`include "../../03_Sequential_Logic/BitShift9R.v"
|
40
03_Sequential_Logic/05_RAM3840/PC_tb.gtkw
Normal file
40
03_Sequential_Logic/05_RAM3840/PC_tb.gtkw
Normal file
@@ -0,0 +1,40 @@
|
||||
[*]
|
||||
[*] GTKWave Analyzer v3.3.104 (w)1999-2020 BSI
|
||||
[*] Thu Dec 22 17:44:56 2022
|
||||
[*]
|
||||
[dumpfile] "/home/micha/gitlab/nand2tetris/03_Sequential_Logic/03_PC/PC_tb.vcd"
|
||||
[dumpfile_mtime] "Thu Dec 22 17:44:20 2022"
|
||||
[dumpfile_size] 627445
|
||||
[savefile] "/home/micha/gitlab/nand2tetris/03_Sequential_Logic/03_PC/PC_tb.gtkw"
|
||||
[timestart] 0
|
||||
[size] 1920 963
|
||||
[pos] -1 -1
|
||||
*-3.000000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
|
||||
[sst_width] 281
|
||||
[signals_width] 160
|
||||
[sst_expanded] 1
|
||||
[sst_vpaned_height] 258
|
||||
@28
|
||||
PC_tb.clk
|
||||
@200
|
||||
-IN
|
||||
@22
|
||||
PC_tb.in[15:0]
|
||||
@28
|
||||
PC_tb.load
|
||||
PC_tb.inc
|
||||
PC_tb.reset
|
||||
@200
|
||||
-OUT
|
||||
@22
|
||||
PC_tb.out[15:0]
|
||||
@200
|
||||
-CMP
|
||||
@22
|
||||
PC_tb.out_cmp[15:0]
|
||||
@200
|
||||
-Test
|
||||
@29
|
||||
PC_tb.fail
|
||||
[pattern_trace] 1
|
||||
[pattern_trace] 0
|
40
03_Sequential_Logic/05_RAM3840/RAM3840_tb.gtkw
Normal file
40
03_Sequential_Logic/05_RAM3840/RAM3840_tb.gtkw
Normal file
@@ -0,0 +1,40 @@
|
||||
[*]
|
||||
[*] GTKWave Analyzer v3.3.104 (w)1999-2020 BSI
|
||||
[*] Sat Dec 31 11:27:32 2022
|
||||
[*]
|
||||
[dumpfile] "/home/micha/gitlab/nand2tetris-fpga/03_Sequential_Logic/05_RAM3840/RAM3840_tb.vcd"
|
||||
[dumpfile_mtime] "Sat Dec 31 11:26:49 2022"
|
||||
[dumpfile_size] 19516827
|
||||
[savefile] "/home/micha/gitlab/nand2tetris-fpga/03_Sequential_Logic/05_RAM3840/RAM3840_tb.gtkw"
|
||||
[timestart] 0
|
||||
[size] 1616 559
|
||||
[pos] -1 -1
|
||||
*-11.000000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
|
||||
[sst_width] 281
|
||||
[signals_width] 160
|
||||
[sst_expanded] 1
|
||||
[sst_vpaned_height] 117
|
||||
@28
|
||||
RAM3840_tb.clk
|
||||
@200
|
||||
-IN
|
||||
@22
|
||||
RAM3840_tb.address[11:0]
|
||||
@29
|
||||
RAM3840_tb.load
|
||||
@22
|
||||
RAM3840_tb.in[15:0]
|
||||
@200
|
||||
-OUT
|
||||
@22
|
||||
RAM3840_tb.out[15:0]
|
||||
@200
|
||||
-CMP
|
||||
@22
|
||||
RAM3840_tb.out_cmp[15:0]
|
||||
@200
|
||||
-Test
|
||||
@28
|
||||
RAM3840_tb.fail
|
||||
[pattern_trace] 1
|
||||
[pattern_trace] 0
|
60
03_Sequential_Logic/05_RAM3840/RAM3840_tb.v
Normal file
60
03_Sequential_Logic/05_RAM3840/RAM3840_tb.v
Normal file
@@ -0,0 +1,60 @@
|
||||
`default_nettype none
|
||||
module RAM3840_tb();
|
||||
|
||||
// IN,OUT
|
||||
reg clk=1;
|
||||
reg [15:0] in;
|
||||
reg [11:0] address;
|
||||
reg load;
|
||||
wire [15:0] out;
|
||||
|
||||
// Part
|
||||
RAM3840 RAM3840(
|
||||
.clk(clk),
|
||||
.address(address),
|
||||
.in(in),
|
||||
.load(load),
|
||||
.out(out)
|
||||
);
|
||||
|
||||
// Simulate
|
||||
always #1 clk=~clk;
|
||||
always @(posedge clk) begin
|
||||
in <= $random;
|
||||
address <= (n<3840)?n:n-3840;
|
||||
load <= (n<3840);
|
||||
end
|
||||
|
||||
// Compare
|
||||
reg [15:0] regRAM [0:3839];
|
||||
always @(posedge clk)
|
||||
if (load) regRAM[address[11:0]] <= in;
|
||||
wire[15:0] out_cmp = regRAM[address[11:0]];
|
||||
|
||||
reg fail = 0;
|
||||
reg [15:0] n = 0;
|
||||
task check;
|
||||
#1
|
||||
if (out != out_cmp)
|
||||
begin
|
||||
$display("FAIL: clk=%1b, address=%12b, in=%16b, load=%1b, out=%16b",clk,address,in,load,out);
|
||||
fail=1;
|
||||
end
|
||||
endtask
|
||||
|
||||
initial begin
|
||||
$dumpfile("RAM3840_tb.vcd");
|
||||
$dumpvars(0, RAM3840_tb);
|
||||
|
||||
$display("------------------------");
|
||||
$display("Testbench: RAM3840");
|
||||
|
||||
for (n=0; n<2*3840;n=n+1)
|
||||
check();
|
||||
|
||||
if (fail==0) $display("passed");
|
||||
$display("------------------------");
|
||||
$finish;
|
||||
end
|
||||
|
||||
endmodule
|
3
03_Sequential_Logic/05_RAM3840/apio.ini
Normal file
3
03_Sequential_Logic/05_RAM3840/apio.ini
Normal file
@@ -0,0 +1,3 @@
|
||||
[env]
|
||||
board = iCE40-HX1K-EVB
|
||||
|
Reference in New Issue
Block a user