mirror of
https://github.com/openhwgroup/cvw
synced 2025-02-11 06:05:49 +00:00
examples cleanup
This commit is contained in:
parent
2d8b0aa650
commit
ee315bd62b
1
.gitignore
vendored
1
.gitignore
vendored
@ -53,3 +53,4 @@ examples/asm/example/example
|
|||||||
examples/C/sum/sum
|
examples/C/sum/sum
|
||||||
examples/C/fir/fir
|
examples/C/fir/fir
|
||||||
|
|
||||||
|
|
||||||
|
Binary file not shown.
58
examples/verilog/xz/distributedmux.sv
Normal file
58
examples/verilog/xz/distributedmux.sv
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
// xz.sv
|
||||||
|
// David_Harris@hmc.edu 30 January 2022
|
||||||
|
// Demonstrate impact of x and z.
|
||||||
|
|
||||||
|
// load with vsim xz.sv
|
||||||
|
|
||||||
|
module testbench();
|
||||||
|
logic [3:0] d0, d1, d2;
|
||||||
|
logic s0, s1, s2;
|
||||||
|
tri [3:0] y;
|
||||||
|
|
||||||
|
distributedmux dut(.d0, .d1, .d2, .s0, .s1, .s2, .y);
|
||||||
|
|
||||||
|
initial begin
|
||||||
|
d0 = 4'b0000; d1 = 4'b0101; // d2 unknown (xxxx)
|
||||||
|
s0 = 0; s1 = 0; s2 = 0;
|
||||||
|
#10; // y should be floating
|
||||||
|
s0 = 1;
|
||||||
|
#10; //y should be driven to 0000
|
||||||
|
s0 = 0; s1 = 1;
|
||||||
|
#10; // y should be driven to 0101
|
||||||
|
s0 = 1;
|
||||||
|
#10; // y should be driven to 0x0x because of contention on bits 0 and 2
|
||||||
|
s0 = 0; s1 = 0; s2 = 1;
|
||||||
|
#10; // y should be driven to unknown because d2 is unknown
|
||||||
|
end
|
||||||
|
endmodule
|
||||||
|
|
||||||
|
module tristate #(parameter WIDTH=32) (
|
||||||
|
input logic [WIDTH-1:0] a,
|
||||||
|
input logic en,
|
||||||
|
output logic [WIDTH-1:0] y);
|
||||||
|
|
||||||
|
assign y = en ? a : 'z;
|
||||||
|
endmodule
|
||||||
|
|
||||||
|
module distributedmux(
|
||||||
|
input logic [3:0] d0, d1, d2,
|
||||||
|
input logic s0, s1, s2,
|
||||||
|
output tri [3:0] y);
|
||||||
|
|
||||||
|
tristate #(4) t0(d0, s0, y);
|
||||||
|
tristate #(4) t1(d1, s1, y);
|
||||||
|
tristate #(4) t2(d2, s2, y);
|
||||||
|
endmodule
|
||||||
|
|
||||||
|
module gpio #(parameter WIDTH=16) (
|
||||||
|
input logic [WIDTH-1:0] GPIOOutVal, GPIOEn,
|
||||||
|
output logic [WIDTH-1:0] GPIOInVal,
|
||||||
|
inout tri [WIDTH-1:0] GPIOPin);
|
||||||
|
|
||||||
|
assign GPIOInVal = GPIOPin;
|
||||||
|
tristate #(1) ts[WIDTH-1:0](GPIOOutVal, GPIOEn, GPIOPin);
|
||||||
|
endmodule
|
||||||
|
|
||||||
|
module silly(output logic [128:0] y);
|
||||||
|
assign y = 'bz;
|
||||||
|
endmodule
|
19
examples/verilog/xz/xz.sv
Normal file
19
examples/verilog/xz/xz.sv
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// xz.sv
|
||||||
|
// David_Harris@hmc.edu 30 January 2022
|
||||||
|
// Demonstrate impact of x and z.
|
||||||
|
|
||||||
|
// load with vsim xz.sv
|
||||||
|
|
||||||
|
module xz(
|
||||||
|
output logic w, x, y, z);
|
||||||
|
|
||||||
|
logic p, q, r;
|
||||||
|
|
||||||
|
// let p be undriven
|
||||||
|
assign q = 1'bz;
|
||||||
|
assign r = 1'bx;
|
||||||
|
|
||||||
|
assign w = q & 1'b1;
|
||||||
|
assign x = q | 1'b1;
|
||||||
|
endmodule
|
||||||
|
|
Loading…
Reference in New Issue
Block a user