fpga added
This commit is contained in:
2109
spartanTest/ALU
Normal file
2109
spartanTest/ALU
Normal file
File diff suppressed because it is too large
Load Diff
1074
spartanTest/ALU.vcd
Normal file
1074
spartanTest/ALU.vcd
Normal file
File diff suppressed because it is too large
Load Diff
26
spartanTest/ALUtb.v
Normal file
26
spartanTest/ALUtb.v
Normal file
@ -0,0 +1,26 @@
|
||||
module ALUtb ();
|
||||
|
||||
reg [3:0] A, B;
|
||||
reg CarryIN;
|
||||
reg [2:0] opCodeA;
|
||||
wire [11:0] bcd;
|
||||
wire CarryOUT, overflow;
|
||||
|
||||
ALU uut (
|
||||
.A(A),
|
||||
.B(B),
|
||||
.CarryIN(CarryIN),
|
||||
.opCodeA(opCodeA),
|
||||
.bcd(bcd),
|
||||
.CarryOUT(CarryOUT),
|
||||
.overflow(overflow)
|
||||
);
|
||||
|
||||
initial begin
|
||||
$dumpfile("ALU.vcd");
|
||||
$dumpvars;
|
||||
A = 4'b1100; B = 4'b1100; CarryIN = 1'b0; opCodeA = 3'b010; #5;
|
||||
$finish;
|
||||
end
|
||||
|
||||
endmodule
|
140
spartanTest/selector
Normal file
140
spartanTest/selector
Normal file
@ -0,0 +1,140 @@
|
||||
#! /usr/bin/vvp
|
||||
:ivl_version "11.0 (stable)";
|
||||
:ivl_delay_selection "TYPICAL";
|
||||
:vpi_time_precision + 0;
|
||||
:vpi_module "/usr/lib/x86_64-linux-gnu/ivl/system.vpi";
|
||||
:vpi_module "/usr/lib/x86_64-linux-gnu/ivl/vhdl_sys.vpi";
|
||||
:vpi_module "/usr/lib/x86_64-linux-gnu/ivl/vhdl_textio.vpi";
|
||||
:vpi_module "/usr/lib/x86_64-linux-gnu/ivl/v2005_math.vpi";
|
||||
:vpi_module "/usr/lib/x86_64-linux-gnu/ivl/va_math.vpi";
|
||||
S_0x558eb92edb80 .scope module, "selectorTB" "selectorTB" 2 1;
|
||||
.timescale 0 0;
|
||||
v0x558eb9317af0_0 .var "A", 3 0;
|
||||
v0x558eb9317bd0_0 .var "ALUY", 7 0;
|
||||
v0x558eb9317ca0_0 .var "B", 3 0;
|
||||
v0x558eb9317da0_0 .net "Y", 7 0, v0x558eb9317740_0; 1 drivers
|
||||
v0x558eb9317e70_0 .var "opCodeA", 2 0;
|
||||
v0x558eb9317f60_0 .var "select", 1 0;
|
||||
S_0x558eb9302140 .scope module, "uut" "selector" 2 9, 3 1 0, S_0x558eb92edb80;
|
||||
.timescale 0 0;
|
||||
.port_info 0 /INPUT 4 "A";
|
||||
.port_info 1 /INPUT 4 "B";
|
||||
.port_info 2 /INPUT 3 "opCodeA";
|
||||
.port_info 3 /INPUT 2 "select";
|
||||
.port_info 4 /INPUT 8 "ALUY";
|
||||
.port_info 5 /OUTPUT 8 "Y";
|
||||
v0x558eb9302350_0 .net "A", 3 0, v0x558eb9317af0_0; 1 drivers
|
||||
v0x558eb93175a0_0 .net "ALUY", 7 0, v0x558eb9317bd0_0; 1 drivers
|
||||
v0x558eb9317680_0 .net "B", 3 0, v0x558eb9317ca0_0; 1 drivers
|
||||
v0x558eb9317740_0 .var "Y", 7 0;
|
||||
v0x558eb9317820_0 .net "opCodeA", 2 0, v0x558eb9317e70_0; 1 drivers
|
||||
v0x558eb9317950_0 .net "select", 1 0, v0x558eb9317f60_0; 1 drivers
|
||||
E_0x558eb93001f0/0 .event edge, v0x558eb9317950_0, v0x558eb9302350_0, v0x558eb9317680_0, v0x558eb9317820_0;
|
||||
E_0x558eb93001f0/1 .event edge, v0x558eb93175a0_0;
|
||||
E_0x558eb93001f0 .event/or E_0x558eb93001f0/0, E_0x558eb93001f0/1;
|
||||
.scope S_0x558eb9302140;
|
||||
T_0 ;
|
||||
%wait E_0x558eb93001f0;
|
||||
%load/vec4 v0x558eb9317950_0;
|
||||
%dup/vec4;
|
||||
%pushi/vec4 0, 0, 2;
|
||||
%cmp/u;
|
||||
%jmp/1 T_0.0, 6;
|
||||
%dup/vec4;
|
||||
%pushi/vec4 1, 0, 2;
|
||||
%cmp/u;
|
||||
%jmp/1 T_0.1, 6;
|
||||
%dup/vec4;
|
||||
%pushi/vec4 2, 0, 2;
|
||||
%cmp/u;
|
||||
%jmp/1 T_0.2, 6;
|
||||
%dup/vec4;
|
||||
%pushi/vec4 3, 0, 2;
|
||||
%cmp/u;
|
||||
%jmp/1 T_0.3, 6;
|
||||
%pushi/vec4 0, 0, 8;
|
||||
%store/vec4 v0x558eb9317740_0, 0, 8;
|
||||
%jmp T_0.5;
|
||||
T_0.0 ;
|
||||
%pushi/vec4 0, 0, 4;
|
||||
%load/vec4 v0x558eb9302350_0;
|
||||
%concat/vec4; draw_concat_vec4
|
||||
%store/vec4 v0x558eb9317740_0, 0, 8;
|
||||
%jmp T_0.5;
|
||||
T_0.1 ;
|
||||
%pushi/vec4 0, 0, 4;
|
||||
%load/vec4 v0x558eb9317680_0;
|
||||
%concat/vec4; draw_concat_vec4
|
||||
%store/vec4 v0x558eb9317740_0, 0, 8;
|
||||
%jmp T_0.5;
|
||||
T_0.2 ;
|
||||
%pushi/vec4 0, 0, 5;
|
||||
%load/vec4 v0x558eb9317820_0;
|
||||
%concat/vec4; draw_concat_vec4
|
||||
%store/vec4 v0x558eb9317740_0, 0, 8;
|
||||
%jmp T_0.5;
|
||||
T_0.3 ;
|
||||
%load/vec4 v0x558eb93175a0_0;
|
||||
%store/vec4 v0x558eb9317740_0, 0, 8;
|
||||
%jmp T_0.5;
|
||||
T_0.5 ;
|
||||
%pop/vec4 1;
|
||||
%jmp T_0;
|
||||
.thread T_0, $push;
|
||||
.scope S_0x558eb92edb80;
|
||||
T_1 ;
|
||||
%vpi_call 2 19 "$dumpfile", "selector.vcd" {0 0 0};
|
||||
%vpi_call 2 20 "$dumpvars" {0 0 0};
|
||||
%pushi/vec4 1, 0, 4;
|
||||
%store/vec4 v0x558eb9317af0_0, 0, 4;
|
||||
%pushi/vec4 2, 0, 4;
|
||||
%store/vec4 v0x558eb9317ca0_0, 0, 4;
|
||||
%pushi/vec4 7, 0, 3;
|
||||
%store/vec4 v0x558eb9317e70_0, 0, 3;
|
||||
%pushi/vec4 240, 0, 8;
|
||||
%store/vec4 v0x558eb9317bd0_0, 0, 8;
|
||||
%pushi/vec4 0, 0, 2;
|
||||
%store/vec4 v0x558eb9317f60_0, 0, 2;
|
||||
%delay 5, 0;
|
||||
%pushi/vec4 1, 0, 4;
|
||||
%store/vec4 v0x558eb9317af0_0, 0, 4;
|
||||
%pushi/vec4 2, 0, 4;
|
||||
%store/vec4 v0x558eb9317ca0_0, 0, 4;
|
||||
%pushi/vec4 7, 0, 3;
|
||||
%store/vec4 v0x558eb9317e70_0, 0, 3;
|
||||
%pushi/vec4 240, 0, 8;
|
||||
%store/vec4 v0x558eb9317bd0_0, 0, 8;
|
||||
%pushi/vec4 1, 0, 2;
|
||||
%store/vec4 v0x558eb9317f60_0, 0, 2;
|
||||
%delay 5, 0;
|
||||
%pushi/vec4 1, 0, 4;
|
||||
%store/vec4 v0x558eb9317af0_0, 0, 4;
|
||||
%pushi/vec4 2, 0, 4;
|
||||
%store/vec4 v0x558eb9317ca0_0, 0, 4;
|
||||
%pushi/vec4 7, 0, 3;
|
||||
%store/vec4 v0x558eb9317e70_0, 0, 3;
|
||||
%pushi/vec4 112, 0, 8;
|
||||
%store/vec4 v0x558eb9317bd0_0, 0, 8;
|
||||
%pushi/vec4 2, 0, 2;
|
||||
%store/vec4 v0x558eb9317f60_0, 0, 2;
|
||||
%delay 5, 0;
|
||||
%pushi/vec4 1, 0, 4;
|
||||
%store/vec4 v0x558eb9317af0_0, 0, 4;
|
||||
%pushi/vec4 2, 0, 4;
|
||||
%store/vec4 v0x558eb9317ca0_0, 0, 4;
|
||||
%pushi/vec4 7, 0, 3;
|
||||
%store/vec4 v0x558eb9317e70_0, 0, 3;
|
||||
%pushi/vec4 112, 0, 8;
|
||||
%store/vec4 v0x558eb9317bd0_0, 0, 8;
|
||||
%pushi/vec4 3, 0, 2;
|
||||
%store/vec4 v0x558eb9317f60_0, 0, 2;
|
||||
%delay 5, 0;
|
||||
%vpi_call 2 25 "$finish" {0 0 0};
|
||||
%end;
|
||||
.thread T_1;
|
||||
# The file index is used to find the file name in the following table.
|
||||
:file_names 4;
|
||||
"N/A";
|
||||
"<interactive>";
|
||||
"selectorTB.v";
|
||||
"selector.v";
|
@ -1,68 +1,20 @@
|
||||
module selector (
|
||||
input [3:0] select,
|
||||
input [7:0] Y,
|
||||
input [3:0] A, B,
|
||||
input [3:0] A,
|
||||
input [3:0] B,
|
||||
input [2:0] opCodeA,
|
||||
output [7:0] s0
|
||||
input [1:0] select,
|
||||
input [7:0] ALUY,
|
||||
output reg [7:0] Y
|
||||
);
|
||||
|
||||
wire [3:0] a0, b0, tempAB, tempYO;
|
||||
wire [7:0] y0;
|
||||
wire [2:0] op0;
|
||||
wire tempsO, temps;
|
||||
|
||||
// Select signals for A
|
||||
and a00 (a0[0], select[0], A[0]);
|
||||
and a01 (a0[1], select[0], A[1]);
|
||||
and a02 (a0[2], select[0], A[2]);
|
||||
and a03 (a0[3], select[0], A[3]);
|
||||
|
||||
// Select signals for B
|
||||
and b00 (b0[0], select[1], B[0]);
|
||||
and b01 (b0[1], select[1], B[1]);
|
||||
and b02 (b0[2], select[1], B[2]);
|
||||
and b03 (b0[3], select[1], B[3]);
|
||||
|
||||
// Select signals for Y
|
||||
and y00 (y0[0], select[2], Y[0]);
|
||||
and y01 (y0[1], select[2], Y[1]);
|
||||
and y02 (y0[2], select[2], Y[2]);
|
||||
and y03 (y0[3], select[2], Y[3]);
|
||||
and y04 (y0[4], select[2], Y[4]);
|
||||
and y05 (y0[5], select[2], Y[5]);
|
||||
and y06 (y0[6], select[2], Y[6]);
|
||||
and y07 (y0[7], select[2], Y[7]);
|
||||
|
||||
// Select signals for opCodeA
|
||||
and op00 (op0[0], select[3], opCodeA[0]);
|
||||
and op01 (op0[1], select[3], opCodeA[1]);
|
||||
and op02 (op0[2], select[3], opCodeA[2]);
|
||||
|
||||
// Combine A and B
|
||||
or or1 (tempAB[0], a0[0], b0[0]);
|
||||
or or2 (tempAB[1], a0[1], b0[1]);
|
||||
or or3 (tempAB[2], a0[2], b0[2]);
|
||||
or or4 (tempAB[3], a0[3], b0[3]);
|
||||
|
||||
// Combine Y and opCodeA
|
||||
or or5 (tempYO[0], y0[0], op0[0]);
|
||||
or or6 (tempYO[1], y0[1], op0[1]);
|
||||
or or7 (tempYO[2], y0[2], op0[2]);
|
||||
or or8 (tempYO[3], y0[3], 1'b0);
|
||||
|
||||
// NOR for select logic
|
||||
nor s01 (tempsO, select[0], select[1]);
|
||||
nor s02 (temps, tempsO, select[3]);
|
||||
|
||||
// Final s0 connections
|
||||
or or9 (s0[0], tempAB[0], tempYO[0]);
|
||||
or or10 (s0[1], tempAB[1], tempYO[1]);
|
||||
or or11 (s0[2], tempAB[2], tempYO[2]);
|
||||
or or12 (s0[3], tempAB[3], tempYO[3]);
|
||||
|
||||
and and13 (s0[4], y0[4], temps);
|
||||
and and14 (s0[5], y0[5], temps);
|
||||
and and15 (s0[6], y0[6], temps);
|
||||
and and16 (s0[7], y0[7], temps);
|
||||
always @(*) begin
|
||||
case (select)
|
||||
2'b00: Y = {4'b0000, A}; // Zero-extend A to 8 bits
|
||||
2'b01: Y = {4'b0000, B}; // Zero-extend B to 8 bits
|
||||
2'b10: Y = {5'b00000, opCodeA}; // Zero-extend opCodeA to 8 bits
|
||||
2'b11: Y = ALUY; // Directly assign ALUY
|
||||
default: Y = 8'b00000000; // Default case for safety
|
||||
endcase
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
59
spartanTest/selector.vcd
Normal file
59
spartanTest/selector.vcd
Normal file
@ -0,0 +1,59 @@
|
||||
$date
|
||||
Sat Jan 18 17:21:23 2025
|
||||
$end
|
||||
$version
|
||||
Icarus Verilog
|
||||
$end
|
||||
$timescale
|
||||
1s
|
||||
$end
|
||||
$scope module selectorTB $end
|
||||
$var wire 8 ! Y [7:0] $end
|
||||
$var reg 4 " A [3:0] $end
|
||||
$var reg 8 # ALUY [7:0] $end
|
||||
$var reg 4 $ B [3:0] $end
|
||||
$var reg 3 % opCodeA [2:0] $end
|
||||
$var reg 2 & select [1:0] $end
|
||||
$scope module uut $end
|
||||
$var wire 4 ' A [3:0] $end
|
||||
$var wire 8 ( ALUY [7:0] $end
|
||||
$var wire 4 ) B [3:0] $end
|
||||
$var wire 3 * opCodeA [2:0] $end
|
||||
$var wire 2 + select [1:0] $end
|
||||
$var reg 8 , Y [7:0] $end
|
||||
$upscope $end
|
||||
$upscope $end
|
||||
$enddefinitions $end
|
||||
#0
|
||||
$dumpvars
|
||||
b1 ,
|
||||
b0 +
|
||||
b111 *
|
||||
b10 )
|
||||
b11110000 (
|
||||
b1 '
|
||||
b0 &
|
||||
b111 %
|
||||
b10 $
|
||||
b11110000 #
|
||||
b1 "
|
||||
b1 !
|
||||
$end
|
||||
#5
|
||||
b10 !
|
||||
b10 ,
|
||||
b1 &
|
||||
b1 +
|
||||
#10
|
||||
b111 !
|
||||
b111 ,
|
||||
b10 &
|
||||
b10 +
|
||||
b1110000 #
|
||||
b1110000 (
|
||||
#15
|
||||
b1110000 !
|
||||
b1110000 ,
|
||||
b11 &
|
||||
b11 +
|
||||
#20
|
@ -1,25 +1,27 @@
|
||||
module selectorTB();
|
||||
|
||||
reg [3:0] select, A, B;
|
||||
reg [7:0] Y;
|
||||
reg [1:0] select;
|
||||
reg [3:0] A, B;
|
||||
reg [7:0] ALUY;
|
||||
reg [2:0] opCodeA;
|
||||
wire [7:0] s0;
|
||||
wire [7:0] Y;
|
||||
|
||||
selector uut (
|
||||
.select(select),
|
||||
.A(A),
|
||||
.B(B),
|
||||
.opCodeA(opCodeA),
|
||||
.s0(s0)
|
||||
.ALUY(ALUY),
|
||||
.Y(Y)
|
||||
);
|
||||
|
||||
initial begin
|
||||
$dumpfile("selector.vcd");
|
||||
$dumpvars;
|
||||
A = 4'b0001; B = 4'b0010; opCodeA = 3'b111; Y = 8'b1111_0000; select = 4'b0010; #5;
|
||||
A = 4'b0001; B = 4'b0010; opCodeA = 3'b111; Y = 8'b1111_0000; select = 4'b0001; #5;
|
||||
A = 4'b0001; B = 4'b0010; opCodeA = 3'b111; Y = 8'b0111_0000; select = 4'b0100; #5;
|
||||
A = 4'b0001; B = 4'b0010; opCodeA = 3'b111; Y = 8'b0111_0000; select = 4'b1000; #5;
|
||||
A = 4'b0001; B = 4'b0010; opCodeA = 3'b111; ALUY = 8'b1111_0000; select = 2'b00; #5;
|
||||
A = 4'b0001; B = 4'b0010; opCodeA = 3'b111; ALUY = 8'b1111_0000; select = 2'b01; #5;
|
||||
A = 4'b0001; B = 4'b0010; opCodeA = 3'b111; ALUY = 8'b0111_0000; select = 2'b10; #5;
|
||||
A = 4'b0001; B = 4'b0010; opCodeA = 3'b111; ALUY = 8'b0111_0000; select = 2'b11; #5;
|
||||
$finish;
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user