kissmoh
Junior Member level 1
- Joined
- Jan 17, 2013
- Messages
- 16
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,443
im trying to make a simple code
i think the two cases work samely
but after implementing it, the results were different(this code is part of image processing module and the final result after passed other modules was checked through monitor)
is there any difference in that two case?
( other values execpt the s_x signal were unsigned value and the simulation using modelsim showed valid result) in that code
Code:
// case 1
// w_buf_x : registered value
localparam
threshold = 3'd2;
reg [7:0] w_buf_0 [2:0];
reg [7:0] w_buf_1 [2:0];
reg [7:0] w_buf_2 [2:0];
wire signed [8:0] s_0, s_1, s_2, s_3;
assign s_0 = (w_buf_1[0] - w_buf_1[2] - threshold);
assign s_1 = (w_buf_2[0] - w_buf_0[2] - threshold);
assign s_2 = (w_buf_2[1] - w_buf_0[1] - threshold);
assign s_3 = (w_buf_2[2] - w_buf_0[0] - threshold);
assign r_0 = (s_0 > 0) ? 1'b1 : 0;
assign r_1 = (s_1 > 0) ? 2'd2 : 0;
assign r_2 = (s_2 > 0) ? 3'd4 : 0;
assign r_3 = (s_3 > 0) ? 4'd8 : 0;
//case 2
assign s_0 = (w_buf_1[0] - w_buf_1[2]);
assign s_1 = (w_buf_2[0] - w_buf_0[2]);
assign s_2 = (w_buf_2[1] - w_buf_0[1]);
assign s_3 = (w_buf_2[2] - w_buf_0[0]);
assign r_0 = (s_0 > threshold) ? 1'b1 : 0;
assign r_1 = (s_1 > threshold) ? 2'd2 : 0;
assign r_2 = (s_2 > threshold) ? 3'd4 : 0;
assign r_3 = (s_3 > threshold) ? 4'd8 : 0;
assign result = r_0 + r_1 + r_2 + r_3;
i think the two cases work samely
but after implementing it, the results were different(this code is part of image processing module and the final result after passed other modules was checked through monitor)
is there any difference in that two case?
( other values execpt the s_x signal were unsigned value and the simulation using modelsim showed valid result) in that code