Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise pattern to fix Coq/Verilog misclassification #4751

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/linguist/heuristics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,9 @@ disambiguations:
- extensions: ['.v']
rules:
- language: Coq
pattern: '\(\*.*?\*\)|(?:^|\s)(?:Proof|Qed)\.(?:$|\s)|(?:^|\s)Require[ \t]+Import\s'
pattern: '(?:^|\s)(?:Proof|Qed)\.(?:$|\s)|(?:^|\s)Require[ \t]+(Import|Export)\s'
- language: Verilog
pattern: '^[ \t]*module\s+[^\s()]+\s+\#?\(|^[ \t]*`(?:ifdef|timescale)\s|^[ \t]*always[ \t]+@'
pattern: '^[ \t]*module\s+[^\s()]+\s+\#?\(|^[ \t]*`(?:define|ifdef|ifndef|include|timescale)|^[ \t]*always[ \t]+@|^[ \t]*initial[ \t]+(begin|@)'
- language: V
pattern: '\$(?:if|else)[ \t]|^[ \t]*fn\s+[^\s()]+\(.*?\).*?\{|^[ \t]*for\s*\{'
- extensions: ['.vba']
Expand Down
81 changes: 81 additions & 0 deletions samples/Verilog/ram.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*--------------------
Original Author: Yuma Ueda
Contact Point: cyan@0x00a1e9.dev
ram.v
Created: 12/19/2019

Copyright 2019 Yuma Ueda

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------*/


`include "defs.v"


module RAM (
input wire [31:0] addr, write_data,
input wire memwrite,
input wire [1:0] storeops,
output wire [31:0] read_data,
input wire CLK, reset
);

reg [7:0] ram [`RAM_COL_MAX-1:0];

always @(posedge CLK) begin
if (reset) begin : rst
integer i;
for (i = 0; i < `RAM_COL_MAX; i = i + 1) begin
ram[i] <= 0;
end
end
else if (memwrite) begin
do_store();
end
end

assign read_data = {
ram[addr],
ram[addr+1],
ram[addr+2],
ram[addr+3]
};

task store_byte;
begin
ram[addr] <= write_data[7:0];
end
endtask

task store_half_word;
begin
ram[addr] <= write_data[15:8];
ram[addr+1] <= write_data[7:0];
end
endtask

task store_word;
begin
ram[addr] <= write_data[31:24];
ram[addr+1] <= write_data[23:16];
ram[addr+2] <= write_data[15: 8];
ram[addr+3] <= write_data[ 7: 0];
end
endtask

task do_store;
begin
(* full_case *)
case (storeops)
`STORE_B: store_byte();
`STORE_H: store_half_word();
`STORE_W: store_word();
endcase
end
endtask
endmodule