-
openassistant_FIFO카테고리 없음 2023. 7. 29. 13:59
This code defines two Verilog modules - fifo and fifo_8k. The first module contains the main logic of the FIFO and the second module specializes it to be an 8-bit wide FIFO with a depth of 16 words. It has two output signals data, ovrf and unrf indicating whether there is data available to be read or not. Additionally this module uses three other signals rdreq, wrreq which indicates when the module wants to read or write from the RAM respectively.
The functionality of the module works by checking for both read and write request at the same time, and throws an error message. Then depending on whether it's reading or writing it will perform different operations such as shifting left or right the contents of the FIFO based on its current state of being either full or empty. Finally it outputs the data from the FIFO or nothing if it is empty or overflowed.
Note that this is just an example and may not work as is. You should verify the correctness of any code before using it in your designs.
ASK : then how about making DMAC???
// This file contains the architecture of the DMAC block module dmac_ctrl (/aconnect, /bconnect, /cconnect, /ddir_in, /cclr_out, /sdr_in, /cdr_out, clk, resetn)( // These inputs/outputs connect the DMAC to external components input aconnect, bconnect, cconnect; // Connect to slave devices input ddir_in; // Data direction input control signal input cclr_out; // Clear clock enable output pin input sdr_in; // Slave device select input input cdr_out; // Clock divider ratio output input clk; // Main system clock input resetn; // Reset enable reg [(31):0] cnt; // Counter register for transfer count wire [(31):0] w_cnt; // Write counter value wire [(31):0] r_cnt; // Read counter value always_ff @(posedge clk) begin : phy_start if (!resetn || ~w_cnt[31]) begin cnt <= w_cnt + 1'; end end always_comb begin : phys_finish // Update counters based on selected mode case (mode) 0: begin cnt <= w_cnt; ccnt <= ((!aclr_in && ~ccc_in) ? ccnt + 1 : ccnt) >> 1; break; 999: begin // Error handling logic goes here end default: begin // Error handling logic goes here end endcase end // Outputs assign aclr_out = aconnect && !ccc_in; assign ccc_out = !aclr_in && ccnt == 31'h00000000; assign cdr_out = 1'b0; // Default value assign cnt = {1{32}}; // Initialize counter register assign clk_en = w_cnt <== 0; assign load = w_cnt; assign sck; // Clock out line endmodule
================
윤리적문제,기술적문제때문에 특정 DMAC를 따라서 해보기에는 무리가 있다.
chat gpt 정도가 좀 일반적인 조언을 해준다. (실무에서 사용 가능 but 아이디어 정도만)
Meta 의 Llama2 는 lit gpt로 로컬환경에서 돌렸을때 output이 윤리적문제로 거부를 하였다(code generation는 전문가의 도움이 필요하다고 함. 따로 chat hf 파일 말고 그냥 Pretrained model을 학습시켜야 함.)
// Assume a microcontroller with two peripherals: Source (SRC) and Destination (DEST) // DMAC transfers data from SRC to DEST without CPU intervention // Register addresses of the DMAC #define DMAC_CTRL_REG 0x40004000 #define DMAC_SRC_REG 0x40004004 #define DMAC_DEST_REG 0x40004008 #define DMAC_SIZE_REG 0x4000400C // Initialize DMAC void initDMAC() { // Set DMAC control register *((volatile uint32_t*)DMAC_CTRL_REG) = 0x0001; // Enable DMAC // Set source and destination addresses *((volatile uint32_t*)DMAC_SRC_REG) = (uint32_t)&SRC; *((volatile uint32_t*)DMAC_DEST_REG) = (uint32_t)&DEST; // Set the size of data to transfer (in bytes) *((volatile uint32_t*)DMAC_SIZE_REG) = 100; } // Start DMAC transfer void startDMAC() { // DMAC will automatically transfer data from SRC to DEST } int main() { initDMAC(); startDMAC(); // Continue with other tasks }