aboutsummaryrefslogtreecommitdiffstats
path: root/spi_master_ss_template.v
diff options
context:
space:
mode:
authorGravatar Peter McGoron 2022-10-23 04:56:56 -0400
committerGravatar Peter McGoron 2022-10-23 04:56:56 -0400
commit31fd1ded97e89e047dc7f032d8bab22fe56a92d2 (patch)
treef4cbde753b92cb4f6c24639dda219159aae46ded /spi_master_ss_template.v
parentadd clean.sh (diff)
factor out code
Diffstat (limited to 'spi_master_ss_template.v')
-rw-r--r--spi_master_ss_template.v17
1 files changed, 14 insertions, 3 deletions
diff --git a/spi_master_ss_template.v b/spi_master_ss_template.v
index eeaf01c..27a4b85 100644
--- a/spi_master_ss_template.v
+++ b/spi_master_ss_template.v
@@ -63,19 +63,30 @@ localparam WAIT_ON_MASTER = 2;
localparam WAIT_ON_ARM_DEASSERT = 3;
reg [2:0] state = WAIT_ON_ARM;
+task master_arm();
+ arm_master <= 1;
+ state <= WAIT_ON_MASTER;
+endtask
+
always @ (posedge clk) begin
case (state)
WAIT_ON_ARM: begin
if (arm) begin
timer <= 1;
- state <= WAIT_ON_SS;
+ if (SS_WAIT == 0) begin
+ master_arm();
+ end else begin
+ timer <= 1;
+ state <= WAIT_ON_SS;
+ end
ss <= 1;
end
end
WAIT_ON_SS: begin
if (timer == SS_WAIT) begin
- arm_master <= 1;
- state <= WAIT_ON_MASTER;
+ master_arm();
+ end else begin
+ timer <= timer + 1;
end
end
WAIT_ON_MASTER: begin