Bài 1
Đề bài
Sơ đồ khối của hệ thống tìm số nhỏ nhất thứ nhất (min1), số nhỏ nhất thứ hai (min2) và vị trí của số nhỏ nhất thứ nhất (index_min1) trong dãy số không dấu đầu vào được trình bày như hình bên dưới.
Thực thi hệ thống trên với = 10
Các ngõ vào I0, I1,…, In-1 là các số nhị phân 4 bit không dấu.
Trường hợp ngõ vào có nhiều hơn 2 giá trị min1, thì ngõ ra index_min1 chỉ vị trí ngõ vào có chỉ số nhỏ hơn.
1 Đề xuất 2 giải thuật thực thi hệ thống trên (sơ đồ khối, giải thích chi tiết).
2 Viết code Verilog mô tả 2 giải thuật đã đề xuất ở trên Sử dụng phần mềm mô phỏng kiểm tra chức năng hệ thống (chụp lại hình kết quả mô phỏng).
3 Đánh giá tài nguyên phần cứng khi thực thi 2 giải thuật đề xuất trên Cyclone V
1.1.1 Giải thuật thứ nhất Đại học Bách khoa TPHCM Trang 3
TIEU LUAN MOI download : skknchat@gmail.com
Đầu tiên, trong sơ đồ giải thuật bộ min_finder, chúng ta kết hợp giá trị của port và số thứ tự của port để tạo thành một mảng IN[i] nhằm thực hiện so sánh Khi so sánh, nếu giá trị của hai port giống nhau, chúng ta sẽ tiếp tục so sánh theo số thứ tự của port đó.
Tiếp theo, ta lưu min_1 và index_min1 tương ứng với giá trị của port 0 và số thứ tự của nó:
0 và min_2 là giá trị của port 1.
Trong quá trình so sánh cặp min_1, index_min1 với giá trị min_2, chúng ta sẽ kiểm tra các giá trị tương ứng của các port từ 1 đến 9 Kết quả sẽ có hai trường hợp xảy ra.
Đầu tiên, nếu cặp min_1 và index_min1 lớn hơn IN[i], chúng ta sẽ thay thế min_1 và index_min1 bằng các giá trị tương ứng của cổng thứ i, đồng thời cập nhật min_2 thành min_1.
Trong bước thứ hai, chúng ta so sánh giá trị của cặp min_1 với IN[i], và nếu min_1 nhỏ hơn IN[i], chúng ta sẽ tiếp tục kiểm tra giá trị của port thứ i với min_2 Nếu min_2 lớn hơn giá trị của port thứ i, chúng ta sẽ cập nhật min_2 với giá trị mới; nếu không, chúng ta sẽ giữ nguyên giá trị hiện tại của min_2.
Code thực hiện: Đại học Bách khoa TPHCM Trang 4
The module `min_finder` is designed to find the minimum values among ten input signals, defined by the parameters `rst`, `clk`, and ten 4-bit inputs (`in0` to `in9`) It outputs two minimum values (`min1`, `min2`), their respective indices (`index_min1`), and a flag (`nflag`) The module initializes registers for input values and temporary storage, using a clock-triggered process to manage the input data Upon reset or when no valid inputs are present, it assigns values to the registers; otherwise, it shifts the input values through the registers The count variable tracks the number of comparisons, decrementing with each clock cycle until the minimum values are determined This implementation ensures efficient processing of input data to identify the minimum values systematically.
{index_min1,min1} = reg_min1; min2 = reg_min2; nflag = 1'b0; end end always @(negedge clk) begin Đại học Bách khoa TPHCM Trang 5
The article discusses a digital design module that involves comparing two 8-bit inputs, in0 and in1, using a comparative logic structure The module, named mf_compare, utilizes two instances of a comparator (cp) to assess the lower and upper nibbles of the inputs, generating outputs for equality (eq) and greater than (grt) conditions The design employs a series of registers to hold intermediate values, with conditional logic determining the final output based on the comparison results This structured approach ensures accurate comparisons and efficient data handling within the digital circuit For further details or to download the complete thesis, contact skknchat@gmail.com.
//grt = 1 if in1