-- LLVM binding -- Copyright (C) 2014 Tristan Gingold -- -- GHDL is free software; you can redistribute it and/or modify it under -- the terms of the GNU General Public License as published by the Free -- Software Foundation; either version 2, or (at your option) any later -- version. -- -- GHDL is distributed in the hope that it will be useful, but WITHOUT ANY -- WARRANTY; without even the implied warranty of MERCHANTABILITY or -- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- for more details. -- -- You should have received a copy of the GNU General Public License -- along with GHDL; see the file COPYING. If not, write to the Free -- Software Foundation, 59 Temple Place - Suite 330, Boston, MA -- 02111-1307, USA. with System; with Interfaces.C; use Interfaces.C; use Interfaces; package LLVM.Core is subtype Cstring is System.Address; function "=" (L, R : Cstring) return Boolean renames System."="; -- Null_Cstring : constant Cstring := Null_Address; Nul : constant String := (1 => Character'Val (0)); Empty_Cstring : constant Cstring := Nul'Address; -- The top-level container for all LLVM global data. See the LLVMContext -- class. type ContextRef is new System.Address; -- The top-level container for all other LLVM Intermediate -- Representation (IR) objects. See the llvm::Module class. type ModuleRef is new System.Address; subtype Bool is int; -- Each value in the LLVM IR has a type, an LLVMTypeRef. See the llvm::Type -- class. type TypeRef is new System.Address; Null_TypeRef : constant TypeRef := TypeRef (System.Null_Address); type TypeRefArray is array (unsigned range <>) of TypeRef; pragma Convention (C, TypeRefArray); type ValueRef is new System.Address; Null_ValueRef : constant ValueRef := ValueRef (System.Null_Address); type ValueRefArray is array (unsigned range <>) of ValueRef; -- Ada pragma Convention (C, ValueRefArray); type BasicBlockRef is new System.Address; Null_BasicBlockRef : constant BasicBlockRef := BasicBlockRef (System.Null_Address); type BasicBlockRefArray is array (unsigned range <>) of BasicBlockRef; -- Ada pragma Convention (C, BasicBlockRefArray); type BuilderRef is new System.Address; -- Used to provide a module to JIT or interpreter. -- See the llvm::MemoryBuffer class. type MemoryBufferRef is new System.Address; -- See the llvm::PassManagerBase class. type PassManagerRef is new System.Address; type Attribute is new unsigned; ZExtAttribute : constant Attribute := 2**0; SExtAttribute : constant Attribute := 2**1; NoReturnAttribute : constant Attribute := 2**2; InRegAttribute : constant Attribute := 2**3; StructRetAttribute : constant Attribute := 2**4; NoUnwindAttribute : constant Attribute := 2**5; NoAliasAttribute : constant Attribute := 2**6; ByValAttribute : constant Attribute := 2**7; NestAttribute : constant Attribute := 2**8; ReadNoneAttribute : constant Attribute := 2**9; ReadOnlyAttribute : constant Attribute := 2**10; NoInlineAttribute : constant Attribute := 2**11; AlwaysInlineAttribute : constant Attribute := 2**12; OptimizeForSizeAttribute : constant Attribute := 2**13; StackProtectAttribute : constant Attribute := 2**14; StackProtectReqAttribute : constant Attribute := 2**15; Alignment : constant Attribute := 31 * 2**16; NoCaptureAttribute : constant Attribute := 2**21; NoRedZoneAttribute : constant Attribute := 2**22; NoImplicitFloatAttribute : constant Attribute := 2**23; NakedAttribute : constant Attribute := 2**24; InlineHintAttribute : constant Attribute := 2**25; StackAlignment : constant Attribute := 7 * 2**26; ReturnsTwice : constant Attribute := 2**29; UWTable : constant Attribute := 2**30; NonLazyBind : constant Attribute := 2**31; type TypeKind is ( VoidTypeKind, -- type with no size HalfTypeKind, -- 16 bit floating point type FloatTypeKind, -- 32 bit floating point type DoubleTypeKind, -- 64 bit floating point type X86_FP80TypeKind, -- 80 bit floating point type (X87) FP128TypeKind, -- 128 bit floating point type (112-bit mantissa) PPC_FP128TypeKind, -- 128 bit floating point type (two 64-bits) LabelTypeKind, -- Labels IntegerTypeKind, -- Arbitrary bit width integers FunctionTypeKind, -- Functions StructTypeKind, -- Structures ArrayTypeKind, -- Arrays PointerTypeKind, -- Pointers VectorTypeKind, -- SIMD 'packed' format, or other vector type MetadataTypeKind, -- Metadata X86_MMXTypeKind -- X86 MMX ); pragma Convention (C, TypeKind); type Linkage
//-----------------------------------------------------
// Design Name : serial_crc_ccitt
// File Name : serial_crc.v
// Function : CCITT Serial CRC
// Coder : Deepak Kumar Tala
//-----------------------------------------------------
module serial_crc_ccitt (
clk ,
reset ,
enable ,
init ,
data_in ,
crc_out
);
//-----------Input Ports---------------
input clk ;
input reset ;
input enable ;
input init ;
input data_in ;
//-----------Output Ports---------------
output [15:0] crc_out;
//------------Internal Variables--------
reg [15:0] lfsr;
//-------------Code Start-----------------
assign crc_out = lfsr;
// Logic to CRC Calculation
always @ (posedge clk)
if (reset) begin
lfsr <= 16'hFFFF;
end else if (enable) begin
if (init) begin
lfsr <= 16'hFFFF;
end else begin
lfsr[0] <= data_in ^ lfsr[15];
lfsr[1] <= lfsr[0];
lfsr[2] <= lfsr[1];
lfsr[3] <= lfsr[2];
lfsr[4] <= lfsr[3];
lfsr[5] <= lfsr[4] ^ data_in ^ lfsr[15];
lfsr[6] <= lfsr[5];
lfsr[7] <= lfsr[6];
lfsr[8] <= lfsr[7];
lfsr[9] <= lfsr[8];
lfsr[10] <= lfsr[9];
lfsr[11] <= lfsr[10];
lfsr[12] <= lfsr[11] ^ data_in ^ lfsr[15];
lfsr[13] <= lfsr[12];
lfsr[14] <= lfsr[13];
lfsr[15] <= lfsr[14];
end
end
endmodule