aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Peter McGoron 2023-04-21 17:39:18 +0000
committerGravatar Peter McGoron 2023-04-21 17:39:18 +0000
commit619734f54eaa8ab12214174b97e3bfca5be9ca1a (patch)
tree5e081f59ff6b0ffe9abaa95dd40aea8048e86a4c
parentlicense and bump version (diff)
add reset pinHEAD1.1master
-rw-r--r--README.md2
-rw-r--r--boothmul.v10
-rw-r--r--sim.cpp34
3 files changed, 33 insertions, 13 deletions
diff --git a/README.md b/README.md
index 322233b..d947e91 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@ Verilog using the [Booth Algorithm][1].
[1]: https://en.wikipedia.org/wiki/Booth%27s_multiplication_algorithm
-This design has been sucessfully synthesized with F4PGA
+This design (v1.0) has been sucessfully synthesized with F4PGA
(`5aafae65883e95e41de2d0294729662dbe0a34f5`) on a Digilent Arty A7-35T
running at a clock speed of 100MHz. The test design is in `arty_test`.
diff --git a/boothmul.v b/boothmul.v
index b6b96d5..5583004 100644
--- a/boothmul.v
+++ b/boothmul.v
@@ -1,4 +1,4 @@
-/* Booth Multiplication v1.0
+/* Booth Multiplication v1.1
* Written by Peter McGoron, 2022.
*
* This source describes Open Hardware and is licensed under the
@@ -25,6 +25,7 @@ module boothmul
)
(
input clk,
+ input rst_L,
input arm,
input [A1_LEN-1:0] a1,
input [A2_LEN-1:0] a2,
@@ -104,7 +105,12 @@ assign debug_state = loop_accul;
`endif
always @ (posedge clk) begin
- if (!arm) begin
+ if (!rst_L) begin
+ loop_accul <= 0;
+ fin <= 0;
+ p <= 0;
+ a1_reg <= 0;
+ end else if (!arm) begin
loop_accul <= 0;
fin <= 0;
end else if (loop_accul == 0) begin
diff --git a/sim.cpp b/sim.cpp
index 7edf0bf..6195f09 100644
--- a/sim.cpp
+++ b/sim.cpp
@@ -29,14 +29,27 @@ static void run_clock() {
main_time++;
}
-static void run(word i, word j) {
+static void run(word i, word j, bool reset_in_middle) {
// Processor is twos-compliment
mod->a1 = i;
mod->a2 = j;
mod->arm = 1;
- while (!mod->fin)
- run_clock();
+ if (!reset_in_middle) {
+ while (!mod->fin)
+ run_clock();
+ } else {
+ int i = 0;
+ while (!mod->fin) {
+ if (i == 10) {
+ mod->rst_L = 0;
+ } else if (i == 20) {
+ mod->rst_L = 1;
+ }
+ run_clock();
+ i++;
+ }
+ }
dword expected = (dword) i * (dword) j;
if (mod->outn != expected) {
@@ -55,16 +68,17 @@ int main(int argc, char **argv) {
mod->clk = 0;
mod->arm = 0;
+ mod->rst_L = 1;
run_clock();
- run(minint, minint);
- run(minint, maxint);
- run(maxint, minint);
- run(maxint, maxint);
+ run(minint, minint, false);
+ run(minint, maxint, false);
+ run(maxint, minint, false);
+ run(maxint, maxint, false);
- for (word i = -20; i < 20; i++) {
- for (word j = - 20; j < 20; j++) {
- run(i, j);
+ for (word i = -40; i < 40; i++) {
+ for (word j = - 40; j < 40; j++) {
+ run(i, j, rand() % 1);
}
}