aboutsummaryrefslogtreecommitdiff
path: root/task5
diff options
context:
space:
mode:
authorgithub-classroom[bot] <66690702+github-classroom[bot]@users.noreply.github.com>2025-09-10 21:59:56 +0000
committerGitHub <noreply@github.com>2025-09-10 21:59:56 +0000
commita186a9a6be2cb0ece7ecf0bcc27e813f5534603d (patch)
treea4cadf53c9e7c47290b54b0446de418a9880e17e /task5
Initial commit
Diffstat (limited to '')
-rw-r--r--task5/.gitignore18
-rw-r--r--task5/card7seg.sv6
-rw-r--r--task5/datapath.sv17
-rw-r--r--task5/dealcard.sv19
-rw-r--r--task5/scorehand.sv8
-rw-r--r--task5/statemachine.sv13
-rw-r--r--task5/task5.sv61
-rw-r--r--task5/tb_datapath.sv7
-rw-r--r--task5/tb_scorehand.sv7
-rw-r--r--task5/tb_statemachine.sv7
-rw-r--r--task5/tb_task5.sv7
11 files changed, 170 insertions, 0 deletions
diff --git a/task5/.gitignore b/task5/.gitignore
new file mode 100644
index 0000000..b0345dc
--- /dev/null
+++ b/task5/.gitignore
@@ -0,0 +1,18 @@
+.DS_Store
+transcript
+tcl_stacktrace.txt
+c5_pin_model_dump.txt
+*.mti
+*.mpf
+*.wlf
+*.qdb
+*.qpg
+*.qtl
+*.qpf
+*.sof
+*.bak
+work/
+db/
+incremental_db/
+simulation/
+output_files/
diff --git a/task5/card7seg.sv b/task5/card7seg.sv
new file mode 100644
index 0000000..6de0793
--- /dev/null
+++ b/task5/card7seg.sv
@@ -0,0 +1,6 @@
+module card7seg(input logic [3:0] card, output logic [6:0] seg7);
+
+ // your code goes here
+
+endmodule
+
diff --git a/task5/datapath.sv b/task5/datapath.sv
new file mode 100644
index 0000000..e5c3f2f
--- /dev/null
+++ b/task5/datapath.sv
@@ -0,0 +1,17 @@
+module datapath(input logic slow_clock, input logic fast_clock, input logic resetb,
+ input logic load_pcard1, input logic load_pcard2, input logic load_pcard3,
+ input logic load_dcard1, input logic load_dcard2, input logic load_dcard3,
+ output logic [3:0] pcard3_out,
+ output logic [3:0] pscore_out, output logic [3:0] dscore_out,
+ output logic [6:0] HEX5, output logic [6:0] HEX4, output logic [6:0] HEX3,
+ output logic [6:0] HEX2, output logic [6:0] HEX1, output logic [6:0] HEX0);
+
+// The code describing your datapath will go here. Your datapath
+// will hierarchically instantiate six card7seg blocks, two scorehand
+// blocks, and a dealcard block. The registers may either be instatiated
+// or included as sequential always blocks directly in this file.
+//
+// Follow the block diagram in the Lab 1 handout closely as you write this code.
+
+endmodule
+
diff --git a/task5/dealcard.sv b/task5/dealcard.sv
new file mode 100644
index 0000000..2fe4e9b
--- /dev/null
+++ b/task5/dealcard.sv
@@ -0,0 +1,19 @@
+// Lucky you! We are giving you this code for free. There is nothing
+// here you need to add or write.
+
+module dealcard(input logic clock, input logic resetb, output logic [3:0] new_card);
+
+logic [3:0] dealer_card;
+
+always_ff @(posedge clock)
+ if (resetb == 0)
+ dealer_card <= 1;
+ else
+ if (dealer_card == 13)
+ dealer_card <= 1;
+ else
+ dealer_card++;
+
+assign new_card = dealer_card;
+
+endmodule
diff --git a/task5/scorehand.sv b/task5/scorehand.sv
new file mode 100644
index 0000000..d6bd6cc
--- /dev/null
+++ b/task5/scorehand.sv
@@ -0,0 +1,8 @@
+module scorehand(input logic [3:0] card1, input logic [3:0] card2, input logic [3:0] card3, output logic [3:0] total);
+
+// The code describing scorehand will go here. Remember this is a combinational
+// block. The function is described in the handout. Be sure to review Verilog
+// notes on bitwidth mismatches and signed/unsigned numbers.
+
+endmodule
+
diff --git a/task5/statemachine.sv b/task5/statemachine.sv
new file mode 100644
index 0000000..1a01db2
--- /dev/null
+++ b/task5/statemachine.sv
@@ -0,0 +1,13 @@
+module statemachine(input logic slow_clock, input logic resetb,
+ input logic [3:0] dscore, input logic [3:0] pscore, input logic [3:0] pcard3,
+ output logic load_pcard1, output logic load_pcard2, output logic load_pcard3,
+ output logic load_dcard1, output logic load_dcard2, output logic load_dcard3,
+ output logic player_win_light, output logic dealer_win_light);
+
+// The code describing your state machine will go here. Remember that
+// a state machine consists of next state logic, output logic, and the
+// registers that hold the state. You will want to review your notes from
+// CPEN 211 or equivalent if you have forgotten how to write a state machine.
+
+endmodule
+
diff --git a/task5/task5.sv b/task5/task5.sv
new file mode 100644
index 0000000..760f423
--- /dev/null
+++ b/task5/task5.sv
@@ -0,0 +1,61 @@
+// This module contains a Verilog description of the top level module
+// Assuming you don't modify the inputs and outputs of the various submodules,
+// you should not have to modify anything in this file.
+
+module task5(input logic CLOCK_50, input logic [3:0] KEY, output logic [9:0] LEDR,
+ output logic [6:0] HEX5, output logic [6:0] HEX4, output logic [6:0] HEX3,
+ output logic [6:0] HEX2, output logic [6:0] HEX1, output logic [6:0] HEX0);
+
+// some local signals
+
+logic fast_clock, slow_clock, resetb;
+logic load_pcard1, load_pcard2, load_pcard3;
+logic load_dcard1, load_dcard2, load_dcard3;
+logic [3:0] pscore, dscore;
+logic [3:0] pcard3;
+
+assign resetb = KEY[3];
+assign slow_clock = KEY[0];
+assign fast_clock = CLOCK_50;
+
+// instantiate the datapath
+
+datapath dp(.slow_clock(slow_clock),
+ .fast_clock(fast_clock),
+ .resetb(resetb),
+ .load_pcard1(load_pcard1),
+ .load_pcard2(load_pcard2),
+ .load_pcard3(load_pcard3),
+ .load_dcard1(load_dcard1),
+ .load_dcard2(load_dcard2),
+ .load_dcard3(load_dcard3),
+ .dscore_out(dscore),
+ .pscore_out(pscore),
+ .pcard3_out(pcard3),
+ .HEX5(HEX5),
+ .HEX4(HEX4),
+ .HEX3(HEX3),
+ .HEX2(HEX2),
+ .HEX1(HEX1),
+ .HEX0(HEX0));
+
+assign LEDR[3:0] = pscore;
+assign LEDR[7:4] = dscore;
+
+// instantiate the state machine
+
+statemachine sm(.slow_clock(slow_clock),
+ .resetb(resetb),
+ .dscore(dscore),
+ .pscore(pscore),
+ .pcard3(pcard3),
+ .load_pcard1(load_pcard1),
+ .load_pcard2(load_pcard2),
+ .load_pcard3(load_pcard3),
+ .load_dcard1(load_dcard1),
+ .load_dcard2(load_dcard2),
+ .load_dcard3(load_dcard3),
+ .player_win_light(LEDR[8]),
+ .dealer_win_light(LEDR[9]));
+
+endmodule
diff --git a/task5/tb_datapath.sv b/task5/tb_datapath.sv
new file mode 100644
index 0000000..64ff5ab
--- /dev/null
+++ b/task5/tb_datapath.sv
@@ -0,0 +1,7 @@
+module tb_datapath();
+
+// Your testbench goes here. Make sure your tests exercise the entire design
+// in the .sv file. Note that in our tests the simulator will exit after
+// 10,000 ticks (equivalent to "initial #10000 $finish();").
+
+endmodule
diff --git a/task5/tb_scorehand.sv b/task5/tb_scorehand.sv
new file mode 100644
index 0000000..0d8f9d8
--- /dev/null
+++ b/task5/tb_scorehand.sv
@@ -0,0 +1,7 @@
+module tb_scorehand();
+
+// Your testbench goes here. Make sure your tests exercise the entire design
+// in the .sv file. Note that in our tests the simulator will exit after
+// 10,000 ticks (equivalent to "initial #10000 $finish();").
+
+endmodule
diff --git a/task5/tb_statemachine.sv b/task5/tb_statemachine.sv
new file mode 100644
index 0000000..032359f
--- /dev/null
+++ b/task5/tb_statemachine.sv
@@ -0,0 +1,7 @@
+module tb_statemachine();
+
+// Your testbench goes here. Make sure your tests exercise the entire design
+// in the .sv file. Note that in our tests the simulator will exit after
+// 10,000 ticks (equivalent to "initial #10000 $finish();").
+
+endmodule
diff --git a/task5/tb_task5.sv b/task5/tb_task5.sv
new file mode 100644
index 0000000..934e417
--- /dev/null
+++ b/task5/tb_task5.sv
@@ -0,0 +1,7 @@
+module tb_task5();
+
+// Your testbench goes here. Make sure your tests exercise the entire design
+// in the .sv file. Note that in our tests the simulator will exit after
+// 100,000 ticks (equivalent to "initial #100000 $finish();").
+
+endmodule