Skip to content

Commit 530b48f

Browse files
committed
Разрежение импульсов
1 parent dbb7202 commit 530b48f

File tree

1 file changed

+34
-13
lines changed

1 file changed

+34
-13
lines changed

messbaue_test_environment/src/messbauer_diff_discriminator_signals.v

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,14 @@
4242
localparam LOWER_THRESHOLD_LOW_PHASE = 4;
4343
localparam FINAL_STATE = 5;
4444

45+
localparam PAUSE_DURATION = 4;
46+
4547
reg enable;
4648
reg[7:0] clk_counter;
4749
reg[7:0] impulse_counter;
4850
reg[7:0] total_impulse_counter;
51+
reg impulse_rejected;
52+
//reg[7:0] selected_impulse_counter;
4953
reg[2:0] state;
5054
reg impulse_selected;
5155

@@ -56,11 +60,12 @@
5660
clk_counter <= 0;
5761
impulse_counter <= 0;
5862
total_impulse_counter <= 0;
59-
impulse_selected <= 0;
63+
// impulse_selected <= 0;
6064
state <= INITIAL_STATE;
6165
lower_threshold <= 0;
6266
upper_threshold <= 0;
6367
enable <= 1;
68+
impulse_rejected <= 1;
6469
end
6570
else
6671
begin
@@ -72,25 +77,35 @@
7277
begin
7378
clk_counter <= 0;
7479
state <= LOWER_THRESHOLD_HIGH_PHASE;
80+
impulse_rejected <= 0;
7581
end
7682
LOWER_THRESHOLD_HIGH_PHASE:
7783
begin
7884
lower_threshold <= 1;
79-
clk_counter <= 0;
80-
//if((impulse_selected == 0 || impulse_counter == 0) && impulse_counter <= IMPULSES_FOR_SELECTION)
81-
if(impulse_selected == 0 && impulse_counter <= IMPULSES_FOR_SELECTION)
85+
if(clk_counter == 1)
86+
begin
87+
// check should we generate upper
88+
if(impulse_counter <= IMPULSES_FOR_SELECTION)
89+
state <= LOWER_THRESHOLD_LOW_PHASE;
90+
else state <= UPPER_THRESHOLD_HIGH_PHASE;;
91+
end
92+
//clk_counter <= 0;
93+
/*if(impulse_counter <= IMPULSES_FOR_SELECTION)
8294
begin
8395
state <= LOWER_THRESHOLD_LOW_PHASE;
84-
impulse_selected <= 1;
96+
// impulse_selected <= 1;
8597
impulse_counter <= impulse_counter + 1;
8698
end
87-
else state <= UPPER_THRESHOLD_HIGH_PHASE;
99+
else
100+
begin
101+
state <= FINAL_STATE; //UPPER_THRESHOLD_HIGH_PHASE;
102+
end*/
88103
end
89104
UPPER_THRESHOLD_HIGH_PHASE:
90105
begin
91-
impulse_selected <= 0;
106+
impulse_rejected <= 1;
92107
upper_threshold <= 1;
93-
if(clk_counter == UPPER_THRESHOLD_DURATION)
108+
if(clk_counter == UPPER_THRESHOLD_DURATION + 1)
94109
state <= UPPER_THRESHOLD_LOW_PHASE;
95110
end
96111
UPPER_THRESHOLD_LOW_PHASE:
@@ -100,9 +115,11 @@
100115
end
101116
LOWER_THRESHOLD_LOW_PHASE:
102117
begin
103-
lower_threshold <= 0;
104-
if(clk_counter == LOWER_THRESHOLD_DURATION)
105-
begin
118+
lower_threshold <= 0;
119+
if(clk_counter >= LOWER_THRESHOLD_DURATION)
120+
begin
121+
if(impulse_rejected == 0)
122+
impulse_counter <= impulse_counter + 1;
106123
total_impulse_counter <= total_impulse_counter + 1;
107124
if(total_impulse_counter == IMPULSES_PER_CHANNEL)
108125
state <= FINAL_STATE;
@@ -112,6 +129,10 @@
112129
FINAL_STATE:
113130
begin
114131
state <= INITIAL_STATE;
132+
//impulse_selected <= 0;
133+
impulse_counter <= 0;
134+
total_impulse_counter <= 0;
135+
//impulse_selected <= 0;
115136
end
116137
default:
117138
begin
@@ -120,9 +141,9 @@
120141
end
121142
else
122143
begin
123-
impulse_selected <= 0;
144+
//impulse_selected <= 0;
124145
total_impulse_counter <= 0;
125-
impulse_selected <= 0;
146+
//impulse_selected <= 0;
126147
end
127148
end
128149
end

0 commit comments

Comments
 (0)